[Python-ideas] Automatic total ordering
Dillon Collins
dillonco at comcast.net
Fri Oct 17 01:23:21 CEST 2008
On Thursday 16 October 2008, George Sakkis wrote:
> On Thu, Oct 16, 2008 at 6:54 PM, Dillon Collins
> <dillonco at comcast.net>wrote:
>
> 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.
>
> How does this help ? If the result of "<=" is True, you still have to
> differentiate between < and == to know whether to stop or proceed with the
> next element in the sequence.
Very true. I spaced and was thinking more towards the general case, rather
than list sorting specifically.
More information about the Python-ideas
mailing list