[Python-3000] Total ordering and __cmp__

Guido van Rossum guido at python.org
Wed Mar 21 05:16:54 CET 2007


On 3/20/07, Collin Winter <collinw at gmail.com> wrote:
> On 3/20/07, Guido van Rossum <guido at python.org> wrote:
> > I haven't taken any action, and it looks like __cmp__ isn't being
> > called. I'd rather not add it back; if you want it back, could you at
> > least write up a brief PEP? A patch would also help; I recall that it
> > was quite a relief being able to cut it out, so I expect that patching
> > it back in would be quite cumbersome.
>
> I'm not wild about the idea of reintroducing it. I'd at least like
> some kind of transition strategy that 2to3 can help with (if not
> implement entirely). Perhaps something like, "if a class defines a
> __cmp__ method but not __lt__, __gt__, __ge__, etc, 2to3 will insert
> those methods, implemented by wrapping calls to cmp() as appropriate".

Or we could just have 2.6 warn about the presence (or use) of __cmp__
-- users can write equivalent code using __lt__ etc. themselves and
probably do a better job. Inserting six new methods sounds like a bit
of a heavy operation for 2to3. The goal of 2to3 is not to convert all
possible programs; it is to make it reasonable to write code that runs
warning-free under 2.6 and and can be converted without manual
massaging to correct, equivalent 3.0 code.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list