l = range(int(1E9))

Ian Kelly ian.g.kelly at gmail.com
Sun May 3 00:51:22 EDT 2015


On Sat, May 2, 2015 at 5:51 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 5/2/2015 5:31 PM, Ian Kelly wrote:
>
>> Would it have been better if range() had been implemented as xrange()
>> from the beginning? Sure, that would have been great. Except for one
>> small detail: the iterator protocol didn't exist back then.
>
>
> For loops originally used the getitem iterator protocol. xrange objects have
> a __getitem__ method, but not __iter__ or __next__.  As Mark pointed out,
> they were introduced in 1993.

I'm aware of getitem iterators; just didn't realize that xrange used
it or was that old.



More information about the Python-list mailing list