[Python-ideas] Automatic total ordering

George Sakkis george.sakkis at gmail.com
Wed Oct 15 16:57:14 CEST 2008


Now that 3.x fixes the arbitrary object comparison wart and drops (?)
__cmp__, it seems it's a good time to do something with the missing rich
comparators gotcha, e.g. given a class that defines __eq__ and __lt__,
automatically provide the rest missing comparisons. Yes, it can be done with
a custom metaclass or (in 2.6+) with a class decorator [1] but (a) 99% of
the time that's what one expects so "explicit is better than implicit"
doesn't count and (b) a bulitin implementation might well be more efficient.
There might be arguments why this would be a bad idea but I really can't
think of any.

George

[1] http://www.voidspace.org.uk/python/weblog/arch_d7_2008_10_04.shtml
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20081015/c2a98f27/attachment.html>


More information about the Python-ideas mailing list