I'm missing something here with range vs. xrange

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Thu Dec 6 17:32:43 EST 2007


Joe Goldthwaite wrote:
> I read that the range function builds a list and that xrange
> returns an iterator and is therefore more efficient.  

This is generally not true.

> In my testing, they both come out to almost exactly the same
> performance wise.  Did something get changed in Python 2.4 to make
> them identical? 

No. Try again with a list of length 10000000.

Regards,


Björn

-- 
BOFH excuse #359:

YOU HAVE AN I/O ERROR -> Incompetent Operator error




More information about the Python-list mailing list