[Python-Dev] range() as iterator (Re: More int/long integration issues)

M.-A. Lemburg mal@lemburg.com
Sat, 12 Apr 2003 13:23:47 +0200

Guido van Rossum wrote:
>>I'd like to work on this.  I've already written a C range() iterator
>>(incorporating PyLongs), and it would be very nice to have it
>>automatically be a lazy range() when used in a loop.
>>In any case, assuming you are quite busy, but would consider this for
>>the 2.4 timeframe, I will do some work on it. If it is already being
>>covered, I'll gladly stay away from it. :)
> range() can't be changed from returning a list until at least Python
> 3.0.

Is this change really necessary ? Instead of changing the semantics
of range() why not have the byte code compiler optimize it's typical

for i in range(10):

In the above case, changing the byte code compiler output would
not introduce any change in semantics. Even better, the compiler
could get rid off the function call altogether.

Marc-Andre Lemburg

Professional Python Software directly from the Source  (#1, Apr 12 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
EuroPython 2003, Charleroi, Belgium:                        73 days left