[Python-ideas] Automatic total ordering

Dillon Collins dillonco at comcast.net
Fri Oct 17 00:54:01 CEST 2008


On Thursday 16 October 2008, Greg Ewing wrote:
> It still bothers me that there is no longer a way to
> provide a single method that performs a three-way
> comparison. Not only because total ordering is the
> most common case, but because it makes comparing
> sequences for ordering very inefficient -- you end up
> comparing everything twice, once for < and once for =.

As a note, you can always implement <= as well, thereby reducing the overhead 
of the 'unimplemented' operations to simply negating their complement.  I do 
this whenever == and < share non-trivial code.



More information about the Python-ideas mailing list