xrange
Bryan
belred1 at yahoo.com
Sun Jun 22 12:08:55 EDT 2003
in 2.3, what is the best way to write this:
for i in xrange(100): print 'Hello'
i used timeit and it seems that repeat is about 10% faster.
timeit -s"from itertools import repeat" "for i in repeat(None, 100): pass"
100000 loops, best of 3: 10.4 usec per loop
timeit "for i in xrange(100): pass"
100000 loops, best of 3: 11.6 usec per loop
will xrange be obsoleted? what is the best idiom for repeating a loop n
times in 2.3 now where you don't care about the index value?
thanks,
bryan
More information about the Python-list
mailing list