convert loop to list comprehension
Paul Rubin
http
Fri Sep 8 21:09:29 EDT 2006
"MonkeeSage" <MonkeeSage at gmail.com> writes:
> Ps. I don't know if xrange is faster...I thought the difference was
> that range created a temporary variable holding a range object and
> xrange created an iterator?
There's no such thing as a "range object"; range creates a list, which
consumes O(n) memory where n is the number of elements. xrange
creates an xrange object, which is a reusable iterator of sorts.
More information about the Python-list
mailing list