xrange questioin

Michael Hudson mwh at python.net
Mon Jul 29 06:42:37 EDT 2002


"Fredrik Lundh" <fredrik at pythonware.com> writes:

> 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.

Is this still true in the iterators age?  I guess I should go look...

Cheers,
M.

-- 
  nonono,  while we're making wild  conjectures about the behavior
  of completely irrelevant tasks, we must not also make serious
  mistakes, or the data might suddenly become statistically valid.
                                        -- Erik Naggum, comp.lang.lisp



More information about the Python-list mailing list