convert loop to list comprehension

MonkeeSage MonkeeSage at
Sat Sep 9 03:14:10 CEST 2006

Paul Rubin wrote:
> "MonkeeSage" <MonkeeSage at> 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.

Aha, thanks for explaining. :)


More information about the Python-list mailing list