Skip to content

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']

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.

2 participants