iterators and views of lists

Daniel Stutzbach daniel at stutzbachenterprises.com
Wed Dec 16 09:18:23 EST 2009


On Wed, Dec 16, 2009 at 5:39 AM, Steven D'Aprano <
steve at remove-this-cybersource.com.au> wrote:

> for item in seq[1:]:
>    process(item)
>
> without making an unnecessary copy of almost all of seq.
>

I use the following idiom:
for i in range(1, len(seq)):
    process(seq[i])

Alternately, if I'm using the blist extension type that I wrote, then
seq[1:] is O(log n).
http://pypi.python.org/pypi/blist/

--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091216/48112ecb/attachment-0001.html>


More information about the Python-list mailing list