Python 2.x breaks cmp() (was Re: A suspected bug)

Aahz Maruch aahz at panix.com
Tue Feb 20 19:42:16 CET 2001


In article <slrn993luj.24c.ssthapa at ntcs-ip45.uchicago.edu>,
 <s-thapa-11 at NOSPAM.alumni.uchicago.edu> wrote:
>Aahz Maruch <aahz at panix.com> wrote:
>>
>>Is there any chance this can be treated as a bug and fixed for the
>>release of 2.1?  Alternatively, given that we're already breaking code
>>with the change in the way complex numbers are handled, should cmp() now
>>raise an exception *every* time the type/class differs?
>
>  If you are referring to the comparision of complex numbers, I'm not
>sure how the ordering would be done.   For example consider 1 and 1j, 
>they have the same magnitude so mathematically speaking there is no
>way to consistently order them like the real numbers where magnitude
>is a more useful measure. IIRC, for any given magnitude n there are an
>infinite number of complex numbers with that magnitude, namely all n*e^(ix)
>for real x.

True enough.  Question is, in the Real World [tm], should everyone who
calls list.sort() be forced to wrap in try/except on the chance that a
pair of complex numbers will sneak in?
-- 
                      --- Aahz (Copyright 2001 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

The problem with an ever-changing .sig is that you have to keep changing it



More information about the Python-list mailing list