efficiency of range() and xrange() in for loops

John Salerno johnjsal at NOSPAMgmail.com
Wed Apr 5 16:09:15 EDT 2006


Steve R. Hastings wrote:

> If Python doesn't currently optimize this case, is there any chance this
> optimization could be added?

I was just asking about this, and apparently it will be changed in 3.0:

Built-in Namespace
     * Make built-ins return an iterator where appropriate (e.g. 
range(),
       zip(), etc.)

To be removed:
     * xrange(): use range() instead [1]



More information about the Python-list mailing list