Final state of underlying sequence in islice
tjreedy at udel.edu
Fri Nov 5 21:05:54 CET 2010
On 11/5/2010 4:58 AM, Raymond Hettinger wrote:
>> Shashank Singh<shashank.sunny.si... at gmail.com> wrote:
>>> Are there any promises made with regard to final state of the underlying
>>> sequence that islice slices?
> Currently, there are no promises or guarantees about the final state
> of the iterator.
I interpret the current doc statement as a promise that becomes
ambiguous when step > 1.
> To the extent the pure Python version in the docs differs from the
> CPython implementation in this regard, it is an accidental
> implementation detail.
> That being said, we could introduce some guarantees (earliest possible
> stop point, latest possible stop point, or decide to leave it
In between earliest and latest, depending on the stop value, is another
possibility. If it is relatively easy to patch the C version to match
the Python version (earliest stop point) I would go for that. It is easy
to skip over and ignore more items, impossible to go back.
Terry Jan Reedy
More information about the Python-list