Alternative to standard C "for"

Diez B. Roggisch deetsNOSPAM at web.de
Sat Feb 5 14:04:29 EST 2005


> First case looks quite nasty, because it's for more complicated
> things, not numerical loops. Second is very nice, but with there's
> problem. If i do ..in range(1, 100000000).. (what I really need
> sometimes), it takes few hundred megs of memory and slows
> down. Are there other good ways for this simple problem? Generators?

Use xrange(). It computes the values as they are needed - not an entire
list.
-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list