Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - rewrote smart list #235

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

WIP - rewrote smart list #235

wants to merge 3 commits into from

Conversation

nyurik
Copy link
Contributor

@nyurik nyurik commented Jan 6, 2020

This is a first draft of the smart list.
It passes all of the existing smartlist tests
(except for full-list reversal, whose behavior has changed),
but the rest of the code has not yet been updated.

Main idea: there is a non-exposed (private) storage class (essentially a list), plus the smart slices (views) into that list. All slices are created on the same level. Slices could be restricted [2:6:1] and non-restricted [::1] or a mix, with some limited support for step != 1.

The biggest unknown - how to handle data insertion beyond the edge of the current slice. Example:

full = smart_list((0,1,2,3])
part0 = full[:1]  # [0]
part1 = full[1:3]  # [1,2]
part1clone = part1[:]  # [1,2]
part2 = full[3:]  # [3]

what should the behavior be after this operation?

  • part1.insert(0,'a')
assert full == [0, 'a', 1, ,2, 3]
assert part0 ==  [0, 'a']
assert part1 == ['a', 1, 2]
assert part1clone == ['a', 1, 2]
assert part2 == [3]
  • part1.insert(100,'z')
assert full == [0, 1, 2, 3, 'z']
assert part0 ==  [0]
assert part1 == [1, 2, 'z']
assert part1clone == [1, 2, 'z']
assert part2 == [3, 'z']

Step one of refactoring - making SmartList into its own
package, with each class having its own file.  No code
changes were made.

Note that SmartList and ListProxy import each other,
so had to import SmartList as a full package name
rather than use from ... import ... construct.
This is a first draft of the smart list.
It passes all of the existing smartlist tests
(except for full-list reversal, whose behavior has changed),
but the rest of the code has not yet been updated.
@saper
Copy link

saper commented Jun 28, 2022

I think your WIP fixes #289 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants