[Python-3000] range() issues

Nick Coghlan ncoghlan at gmail.com
Sat Apr 26 16:02:41 CEST 2008


Alexander Belopolsky wrote:
> Facundo Batista <facundobatista <at> gmail.com> writes:
>> Ahá! So, as ints are unbound in Python, I could easily do:
>>
>>>>> r = range(1,1000000000000000000000)
> 
> The problem with supporting this is that len(r) will raise overflow error.
> It would be nice to get rid of the limitation on len(), but it will be hard
> and may not be possible to do efficiently.

My personal preference is that we stay within the bounds of what was 
possible with the 2.x range() that returned a list instead of a 
customised object: start, stop and step are unbounded, but the overall 
length of the resulting sequence cannot exceed sys.maxsize.

All that needs to be done to make this consistent is to move the length 
calculation into the range object's constructor (and Alexander has 
already provided a patch to do this in issue 2690)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-3000 mailing list