[Python-ideas] Automatic comparisons by default
raymond.hettinger at gmail.com
Tue Mar 15 20:26:33 CET 2011
On Mar 15, 2011, at 12:17 PM, Masklinn wrote:
> Still, there should only be need for two operators to provide total ordering, and having to reimplement every single operator correctly is probably trickier than implementing just two of them.
I think we gave this up when rich comparisons were accepted into the language. The whole idea was that operators can be overridden individually. In addition, they are not simple True/False predicates anymore; instead, they can return NotImplemented which can trigger other calls, or they can return other objects such as vectors.
In other words, the added flexibility means that all bets are off in terms of simple implied relationships. For some purposes, this was an empowering net-win. For other purposes, it is a little inconvenient (making you specify all six of the methods instead of just one).
More information about the Python-ideas