[Python-Dev] decorate-sort-undecorate

Alex Martelli aleaxit at yahoo.com
Tue Oct 14 04:01:10 EDT 2003


On Tuesday 14 October 2003 05:31 am, Guido van Rossum wrote:
   ...
> After reading this exchange, I'm not sure I agree with Tim about the
> importance of avoiding to compare the full records.  Certainly the
> *cost* of that comparison doesn't bother me: I expect it's usually
> going to be a tuple or list of simple types like ints and strings, and
> comparing those is pretty efficient.

I have and have seen many use cases where the things being sorted
are dictionaries (comparisons can be costlier) or instances (they can
be non-comparable).

I agree that the "stable" nature of sorting is not all that important in
our context.  But avoiding whole-record comparison in the general
case seems important enough to me that I'd accept any arbitrary
non-comparing behavior (e.g. making the id of the thing being sorted
the secondary key!-) rather than default to whole-record compares.


Alex




More information about the Python-Dev mailing list