Guido rethinking removal of cmp from sort method

Mel mwilson at the-wire.com
Thu Mar 24 10:41:54 EDT 2011


Carl Banks wrote:

> On Mar 23, 1:38 pm, Paul Rubin <no.em... at nospam.invalid> wrote:
>> Well, I thought it was also to get rid of 3-way cmp in general, in favor
>> of rich comparison.
>
> Supporting both __cmp__ and rich comparison methods of a class does
> add a lot of complexity.  The cmp argument of sort doesn't.
>
> The cmp argument doesn't depend in any way on an object's __cmp__
> method, so getting rid of __cmp__ wasn't any good readon to also get
> rid of the cmp argument; their only relationship is that they're
> spelled the same.  Nor is there any reason why cmp being a useful
> argument of sort should indicate that __cmp__ should be retained in
> classes.

I would have thought that the upper limit of cost of supporting cmp= and
key= would be two different internal front-ends to the internal
internal sort.

	Mel.




More information about the Python-list mailing list