iterating in reverse

Erik Max Francis max at alcyone.com
Fri Jan 17 05:55:13 EST 2003


"Jonathan P." wrote:

> This looks like the best bet so far short of using 2.3.
> One thing though, would using xrange instead of range
> be preferable?

It might.  xrange is always preferable to range if you expect that the
number of elements in the range -- that is, the size of the list it has
to calculate -- could be very large.  If it is, then the proxy object
xrange builds is probably going to have better performance (in terms of
memory).  If you expect they'll always be pretty small, then range will
be perform better (in terms of speed).

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ I am a gentlemen:  I live by robbing the poor.
\__/ George Bernard Shaw
    Kepler's laws / http://www.alcyone.com/max/physics/kepler/
 A proof of Kepler's laws.




More information about the Python-list mailing list