how best to iterate i times ?
Mike Rovner
mike at nospam.com
Wed Mar 17 14:25:55 EST 2004
Randall Smith wrote:
> for i in range(100000):
> dothis()
>
> I like how clean this syntax is, but this method is very wasteful.
> The list created by range(100000) consumes a fair amount of memory
> and it is only used to iterate.
...
> So, question is: What is the efficient, elegant, pythonic way to
> iterate with integers?
Solely for that purpose 'xrange' was created:
for i in xrange(100000):
dothis()
HTH,
Mike
More information about the Python-list
mailing list