xslice idea | a generator slice

Fábio Santos fabiosantosart at gmail.com
Thu Jul 11 15:58:49 EDT 2013


On 11 Jul 2013 17:38, "Oscar Benjamin" <oscar.j.benjamin at gmail.com> wrote:
>
> On 11 July 2013 17:21, Russel Walker <russ.pobox at gmail.com> wrote:
> > To confess, this is the second time I've made the mistake of trying to
implement generator like functionality of a builtin when there already is
on in itertools. Need to start studying that module abit more I think. I'm
looking at the docs now and I see there are actually a couple of
isomethings().
>
> Your xslice (or mine) would still be better than islice when the step
> size is large; islice has to iterate over all the skipped elements
> which could be wasteful if the input is indexable. Also islice doesn't
> support negative values for start, stop or step which xslice does.

Isn't all of itertools implemented in C? If we are not using a python-level
and not-so-fast __getitem__ I would wager the C version is a lot faster.

And if the input is indexable could I assume that it is not too large to
have around in memory and thus any speed increase in looping over it would
be tiny?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130711/73c233b7/attachment.html>


More information about the Python-list mailing list