convert loop to list comprehension
MonkeeSage
MonkeeSage at gmail.com
Fri Sep 8 21:14:10 EDT 2006
Paul Rubin wrote:
> "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.
Aha, thanks for explaining. :)
Regards,
Jordan
More information about the Python-list
mailing list