[Numpy-discussion] Quick Question about Optimization

Eric Firing efiring at hawaii.edu
Mon May 19 15:58:34 EDT 2008


Robin wrote:
> Also you could use xrange instead of range...
> 
> Again, not sure of the size of the effect but it seems to be
> recommended by the docstring.

No, it is going away in Python 3.0, and its only real benefit is a 
memory saving in extreme cases.

 From the Python library docs:
"The advantage of xrange() over range() is minimal (since xrange() still 
has to create the values when asked for them) except when a very large 
range is used on a memory-starved machine or when all of the range's 
elements are never used (such as when the loop is usually terminated 
with break)."

Eric



More information about the NumPy-Discussion mailing list