[Python-Dev] Re: Re: lists v. tuples
Raymond Hettinger
python@rcn.com
Sun, 16 Mar 2003 15:43:49 -0500
> [Andrew Koenig]
> > Yes. If you want to present a 3-way comparison to users, an
> > underlying 3-way comparison is the fastest way to do it. The trouble
> > is that a 3-way comparison is definitely not the fastest way to
> > present a 2-way comparison to users.
> >
> > So if you want users to see separate 2-way and 3-way comparisons,
> > I think the fastest way to implement them is not to try to force
> > commonality where none exists.
>
> This seems an argument for keeping both __cmp__ and the six __lt__
> etc. Yet TOOWTDI makes me want to get rid of __cmp__.
Recent experience with sets.py shows that __cmp__ has a high
PITA factor when combined rich comparisons. There was no
good way to produce all of the desired behaviors:
* <, <=, >, >= having subset interpretations
* __cmp__ being marked as not implemented
* cmp(a,b) not by-passing __cmp__ when __lt__ and __eq__
were defined.
The source of the complications is that comparing Set('a') and Set('b')
returns False for *all* of <, <=, ==, >=, >. Internally, three-way
compares relied on the falsehood of some implying the truth of
others.
Raymond Hettinger
#################################################################
#################################################################
#################################################################
#####
#####
#####
#################################################################
#################################################################
#################################################################