How many is "too many" with lists?
Neel Krishnaswami
neelk at brick.cswv.com
Tue May 2 22:52:57 EDT 2000
Courageous <jkraska1 at san.rr.com> wrote:
>
> Well, this is a bit off the subject, but in recent Python
> misadventures, I'm pretty sure that
>
> for i in range ( 1000000 ):
>
> definitely isn't the right way to loop............
You can use xrange(), which doesn't allocate a whole list, but instead
returns an object with __getitem__ methods that return the right
integers to emulate a range. When you need to loop over 10 million
elements it becomes helpful. :)
Neel
More information about the Python-list
mailing list