Guido rethinking removal of cmp from sort method

Stefan Behnel stefan_ml at behnel.de
Mon Mar 14 03:38:46 EDT 2011


Steven D'Aprano, 13.03.2011 13:59:
> The removal of cmp from the sort method of lists is probably the most
> disliked change in Python 3. On the python-dev mailing list at the
> moment, Guido is considering whether or not it was a mistake.
>
> If anyone has any use-cases for sorting with a comparison function that
> either can't be written using a key function, or that perform really
> badly when done so, this would be a good time to speak up.

As Raymond Hettinger and Daniel Stutzbach pointed out in that thread, the 
memory overhead is much lower in Python 3.2 and also depends on the usage. 
If memory is a problem, it can still be traded for time by sorting in 
multiple (stable) passes with smaller keys. It rarely is a problem in 
practice, though, and Guido's initial post seems to suggest that as well.

Stefan




More information about the Python-list mailing list