[Python-Dev] range objects in 3.x

Guido van Rossum guido at python.org
Fri Sep 23 23:04:16 CEST 2011


On Fri, Sep 23, 2011 at 1:23 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> The only reason I'm aware of at the moment is to prevent loss of
> functionality from 2.x range to 3.x range.
>
> I'm -0 with a decision to not have range be orderable; but I understand
> there are bigger fish to fry.  :)

I don't believe there's a valid use case for ordering ranges. As for
backwards compatibility, apparently nobody cares or we would've heard
about it.

> My original concern was that the comparison methods were there at all, but
> looking around I see object has them, so it makes sense to me now. I had
> thought I would have to implement them if I went ahead with an frange (for
> floats).

[...]> So the question becomes, Why does it implement the Sequence
ABC? Because the
> original range returned a list and those operations made sense?

Because all operations on Sequence make sense: you can iterate over a
range, it has a definite number of items, and so on; all other
sequence operations can be derived from that easily (and in fact they
almost all be done in O(1) time).

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list