[Python-3000] range() issues

Nick Coghlan ncoghlan at gmail.com
Sun Apr 27 16:29:47 CEST 2008


Alexander Belopolsky wrote:
> On Sat, Apr 26, 2008 at 2:49 PM, Facundo Batista
> <facundobatista at gmail.com> wrote:
> 
>>  Which should the range() definition be, in your words?
> 
> In terms of ABCs,  range(..) is a Sized Iterable in the current
> implementation.  It is not a Sequence because it is not a Container
> and does not support slicing.  The idea to support x in range(..) was
> discussed last year [1]  and appears to have been accepted but not
> implemented. I understand that slicing support is in the works. [2]
> 
> I believe it would make sense to turn range(..) into a Sequence.  Here
> are my reasons:
> 
> 1. It will be easy to explain what range(..) is: "a sequence of
> integers from start to stop, excluding stop, skipping step".
> 
> 2. There will be fewer 2 to 3 incompatibilities.
> 
> [1] http://mail.python.org/pipermail/python-3000/2007-July/009028.html
> [2] http://bugs.python.org/msg65807

I like this as a goal - I'll make sure to find the time to help review 
any patches aimed at achieving it (starting with the one to cache the 
length of the range during object creation).

Cheers,
Nick.

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


More information about the Python-3000 mailing list