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 usage:
for i in range(10): pass
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.