[Python-ideas] Implement comparison operators for range objects

Alexander Belopolsky alexander.belopolsky at gmail.com
Sat Oct 15 19:04:50 CEST 2011


On Sat, Oct 15, 2011 at 12:47 PM, Guido van Rossum <guido at python.org> wrote:
..
> I remember in the past thinking about unifying slice() and range() and
> I couldn't do it. I still can't. I think they should remain separate.

One of the issues with slices is that they are deliberately made
unhashable to prevent slicing of dictionaries.  I am not sure range()
objects need to be hashable.  To me they are more like *lists* of
equally spaced integers rather than *tuples*.  (My reasons are not
strong, but FWIW they are: (1) tuples are usually containers of
heterogeneous objects and regular sequences are lists; and (2) 2.x
range() (not xrange()) returns a list rather than a tuple.)  On the
other hand, making range() objects hashable will put an end to
requests for writable .start, .stop, .step.



More information about the Python-ideas mailing list