[PyAR2] Programming Challenge II - One is the Magic Number

W W srilyk at gmail.com
Tue Oct 28 13:53:57 CET 2008

On Tue, Oct 28, 2008 at 6:42 AM, <gslindstrom at gmail.com> wrote:

> It's much better to use xrange() -- as you did -- for things like this. If
> you use range(), Python will create a list and then traverse through it. In
> our case, it will make an array with 1,000,000 elements. xrange() creates
> generator which creates the values as they are used.

Heh... yeah, I know :D Plenty of discussion on the tutor list about that.
I'm not sure how long it takes one vs. the other, but I'm sure it's orders
of magnitude!

But it's good to point out the difference for those who aren't familiar.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/mailman/private/pyar2/attachments/20081028/b017cbfb/attachment.htm>

More information about the PyAR2 mailing list