Speeding up a script -- looking for ideas
Richard Bow
donkan7 at yahoo.com
Sun Oct 20 06:50:22 EDT 2002
Erik Max Francis <max at alcyone.com> wrote in
news:3DB26BA3.DEB4722E at alcyone.com:
> One obvious optimization is that you're using range with huge values,
> which is going to be expensive -- range returns a list, so calling it
> with large values will create an enormous list, which is wasteful if all
> you plan on doing is enumerating it. Try using xrange, or iterating
> manually instead.
Well, range does return a list, but the list is reinitialized to [] for
each n, so it never has more than 2 (and hoping for 3) objects (so far,
i.e, up to n = 1,200,000).
Could you explain what you mean by "iterating manually"?
I'll take a look at xrange.
Thanks,
Richard Bow
More information about the Python-list
mailing list