Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

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.

----------
nosy: +rhettinger, serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33040>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to