efficiency of range() and xrange() in for loops
Alex Martelli
aleaxit at yahoo.com
Wed Apr 5 22:15:20 EDT 2006
Steve R. Hastings <steve at hastings.org> wrote:
...
> Actually, for many uses of "for i in (range|xrange)", you only need the
> value of i, and you aren't doing anything with the integer object. You
Then, the speediest approach may be completely different:
import itertools
for i in itertools.repeat(None, N):
...
Remember, when you're thinking "blazing speed", think itertools.
Alex
More information about the Python-list
mailing list