[issue21744] itertools.islice() goes over all the pre-initial elements even if the iterable can seek

Jesús Cea Avión report at bugs.python.org
Fri Jun 13 06:02:27 CEST 2014


New submission from Jesús Cea Avión:

If L is a big sequence and I do "itertool.islice(L, 1000000, None)", islice will go over a million elements before returning the first that I actually cared.

Since L is a sequence, islice could go directly to the element 1000000.

My program performance improved hugely replacing a "for i in L[p:]" for "for i in (L[p] for p in range(p, len(L)))".

Using itertools and doing "for i in itertools.islice(L, p, None)" is massively inefficient.

----------
components: Extension Modules
messages: 220417
nosy: jcea
priority: normal
severity: normal
status: open
title: itertools.islice() goes over all the pre-initial elements even if the iterable can seek
type: enhancement
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21744>
_______________________________________


More information about the Python-bugs-list mailing list