This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients rhettinger, serhiy.storchaka, tttnns
Date 2018-03-10.10:30:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1520677836.33.0.467229070634.issue33040@psf.upfronthosting.co.za>
In-reply-to
Content
I do not think this is suitable for the itertools module. It is designed to work with iterators, i.e. with objects that support the iterator protocol. What if the iterable change the size during iteration? Should the islice iterator produce less or larger number of items than the initial estimation? Or detect this change and raise an error? Should it revive the iteration if new items were added after consuming the last item? These design questions should have thoughtful answers. And handling all corner cases will complicate the code. I afraid that after adding support of negative start and stop we will get a request for supporting negative step.

It is possible to implement support of negative indices for arbitrary iterators using tee() or deque, but this will complicate the islice() code even more for a small niche case.

This may be a use case for the new module that works specially with sequences. It will be added once we will have enough use cases.
History
Date User Action Args
2018-03-10 10:30:36serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, tttnns
2018-03-10 10:30:36serhiy.storchakasetmessageid: <1520677836.33.0.467229070634.issue33040@psf.upfronthosting.co.za>
2018-03-10 10:30:36serhiy.storchakalinkissue33040 messages
2018-03-10 10:30:35serhiy.storchakacreate