xrange questioin

Fredrik Lundh fredrik at pythonware.com
Sat Jul 27 19:32:45 EDT 2002


Gerald Squelart wrote:

> Ok, let me rephrase Chris' question for a simpler case:
> What is better: for x in range(n) or for x in xrange(n)?
> (with n is relatively small, like 10 or 100)

for in range() is usually a few percent faster, but if you do some-
thing inside the loop, you'll hardly notice the difference.

if performance matters a lot, I suggest benchmarking.

</F>





More information about the Python-list mailing list