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

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Aug 15 06:15:54 CEST 2006

On Aug 14, 2006, at 10:34 PM, Nick Coghlan wrote:

> Alexander Belopolsky wrote:
>> 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.

The slice objects support a single method "indices", which I have to  
admit I've have not seen before a minute ago.  (I've grepped through  
the standard library and did not see it used anywhere).   The slice  
attributes start/stop/step are probably more useful, but I don't see  
why those cannot be added to the range object.

> 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.

How would that hurt reusing them for slicing?

More information about the Python-3000 mailing list