On 10/29/07, David A. Wheeler <[EMAIL PROTECTED]> 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
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com