[Python-Dev] total ordering.

Jason Orendorff jason.orendorff at gmail.com
Thu May 18 21:34:30 CEST 2006


Vladimir,

Your examples seem to indicate that you've misunderstood the change
that's proposed for Python 3000.  Especially this:

On 5/17/06, Vladimir 'Yu' Stepanov <vys at renet.ru> wrote:
>                 # BEGIN: Emulation python3000
>                 if type(a) is not type(b) and (
>                                 not operator.isNumberType(a) or
>                                 not operator.isNumberType(b)
>                         ):
>                         raise TypeError("python3000: not-comparable types", (a,b))
>                 # END: Emulation python3000

Python 3000 will not do anything like this.  It'll try a.__cmp__(b),
and failing that b.__cmp__(a) (but imagine this using tp_ slots
instead of actual Python method calls), and if both return
NotImplemented, it'll throw a TypeError (rather than guess, which is
what it does now).

There's a lot of legacy oddness in PyObject_RichCompare() and its many
helper functions; presumably they'll delete some of that, but it won't
be anything you care about.

Comparison with None should also continue to work as it does now,
unless I missed something.

-j


More information about the Python-Dev mailing list