Guido rethinking removal of cmp from sort method

Terry Reedy tjreedy at udel.edu
Fri Apr 1 14:57:48 EDT 2011


On 4/1/2011 3:45 AM, Paul Rubin wrote:
> What happens then is you define a new interface.

Like key= versus cmp=
> In Microsoft-speak if
> the IWhatever interface needs an incompatible extension like new
> parameters, they introduce IWhatever2 which supports the new parameters.
> They change the implementation of IWhatever so it becomes a wrapper for
> IWhatever2 setting the new parameters to default values, to keep
> implementing the old behavior.

If cmp had been left (or were reinstated) but its implementation changed 
internally to use cmp_to_key to make it a wrapper for key, you would be 
happy? 2to3 could probably gain a fixer to change
.sort(cmp=f) # to
import functools import cmp_to_key
.sort(key=functools.cmp_to_key(f))
I know some would not like this because interface change is not their 
real concern.
-- 
Terry Jan Reedy


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /