[Python-3000] Please re-add __cmp__ to python 3000
Steven Bethard
steven.bethard at gmail.com
Mon Oct 29 21:04:56 CET 2007
On 10/29/07, David A. Wheeler <dwheeler at dwheeler.com> wrote:
> I think several postings have explained better than I have on why __cmp__ is still very valuable. (See below.)
>
> Guido van Rossum posted earlier that he was willing to entertain a PEP to restore __cmp__, so I've attempted to create a draft PEP, posted here:
> http://www.dwheeler.com/misc/pep-cmp.txt
> Please let me know if it makes sense. Thanks.
I think the PEP's a little misleading in that it makes it sound like
defining __lt__, __gt__, etc. is inefficient. I think you want to be
explicit about where __lt__, __gt__ are efficient, and where __cmp__
is efficient. For example::
* __lt__ is more efficient for sorting (given the current implementation)
* __cmp__ is more efficient for comparing sequences like tuples, where
you always need to check for equality first, and you don't want to
have to do an == check followed by a < check if you can do them both
at the same time. (This is basically the same argument as for Decimal
-- why do two comparisons when you can do one?)
STeVe
--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
More information about the Python-3000
mailing list