[Python-ideas] Should range() == range(0)?

Nick Coghlan ncoghlan at gmail.com
Mon May 7 09:06:59 CEST 2012


On Mon, May 7, 2012 at 3:16 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Also I can't remember seeing a plethora of use cases for
> comparing range objects.

Most of the changes to range() in 3.3 are about making them live up to
their claim to implement the Sequence ABC. The approach taken to
achieve this is to follow the philosophy that a Python 3.3 range
object should behave as much as possible like a memory efficient
representation for a tuple of regularly spaced integers (but ignoring
the concatenation and repetition operations that tuples support but
aren't part of the Sequence ABC).

Having range() return an empty range in the same way that tuple()
returns an empty tuple would be a natural extension of that
philosophy.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list