
On Thu, Jan 21, 2021, at 19:19, Chris Angelico wrote:
Yeah, I don't think that'll work if you slice more than once, especially with some iteration in between.
I think part of the point of this implementation [or the other person's suggestion of having a "collection view", which amounts to the same thing] is that iterating wouldn't consume items anymore. Which does make it incompatible with enumerate currently returning an iterator, though, in situations where the iteration is dropped and picked up again.
The precise semantics for mixing iteration and slicing are complex enough and variable enough that you may as well just go for a concrete list at that point.
I do think it's possible to have well-defined semantics [next() could simply return self[0] and increment a value to be added to input indices], but it's probably not worth it. I'd say this and e.g. similar map/zip functions belong in a "sequencetools" module rather than replacing the builtin, so that compatibility in these situations doesn't need to be maintained.