iterators and views of lists

Gregory Ewing greg.ewing at canterbury.ac.nz
Sat Dec 19 00:10:17 EST 2009


Terry Reedy wrote:
> On the other hand, Python indexes are a form of 
> random access iterator, the top of the hierarchy.

The term "random access iterator" seems oxymoronic to
me. Iteration is all about operating on things in
sequence. If you're accessing elements arbitrarily,
then you're not iterating.

> Python, traditionally, only came with one mutable builtin sequence type, 
> so the sort function was made a method of that type.

Also it probably operates rather more efficiently
than a generic one would, as it doesn't have to go
through a general mechanism to access elements, but
can take advantage of its knowledge of the internal
structure of a list.

-- 
Greg



More information about the Python-list mailing list