[Python-3000] [Python-Dev] Type of range object members

Nick Coghlan ncoghlan at gmail.com
Tue Aug 15 04:34:18 CEST 2006


Alexander Belopolsky wrote:
> 
> On Aug 14, 2006, at 10:01 PM, Nick Coghlan wrote:
> 
>> Guido van Rossum wrote:
>>> Methinks that as long as PyIntObject uses long (see intobject.h)
>>> there's no point in changing this to long.
>>
>> Those fields are going to have to change to Py_Object* eventually if 
>> xrange() is going to become the range() replacement in Py3k. . .
>>
> 
> In this case it will become indistinguishable from
> 
> typedef struct {
>     PyObject_HEAD
>     PyObject *start, *stop, *step;      /* not NULL */
> } PySliceObject;
> 
> See sliceobject.h .  Would it make sense to unify rangeobject with 
> PySliceObject?
> 

Not really. The memory layouts may end up being the same in Py3k, but they're 
still different types. The major differences between the two types just happen 
to lie in the methods they support (as defined by the value of the type 
pointer in PyObject_HEAD), rather than the data they contain.

Besides, the range object may actually keep the current optimised behaviour 
for dealing with PyInt values, only falling back to PyObject* if one of start, 
stop or step was too large to fit into a PyInt.

Cheers,
Nick.

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


More information about the Python-3000 mailing list