While we're talking about annoyances
Michael Hoffman
cam.ac.uk at mh391.invalid
Wed May 2 09:59:53 EDT 2007
Steven D'Aprano wrote:
> On Wed, 02 May 2007 06:10:54 +0000, Tim Roberts wrote:
>> I've tended to favor the "Schwarzian transform" (decorate-sort-undecorate)
>> because of that.
>
> That's what the key= argument does. cmp= is slow because the comparison
> function is called for EVERY comparison. The key= function is only called
> once per element.
Right. Using sort(key=keyfunc) is supposed to be faster than
decorate-sort-undecorate. And I think it is clearer too.
--
Michael Hoffman
More information about the Python-list
mailing list