extended slicing and negative stop value problem

Ian Kelly ian.g.kelly at gmail.com
Tue Aug 23 20:12:43 CEST 2011


On Aug 21, 2011 1:34 PM, "Max" <maxmoroz at gmail.com> wrote:
> > a[0:11][::-1]
> > # Instead of a[10:-1:-1], which looks like it should work, but doesn't.
>
> It works nicely, but it is 1.3 times slower in my code (I am surprised
> the interpreter doesn't optimize this).

Have you tried reverse()? I haven't timed it, but since it merely creates an
iterator rather than a second copy, you may get better performance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110823/3fd26108/attachment.html>


More information about the Python-list mailing list