[Python-Dev] decorate-sort-undecorate

Alex Martelli aleaxit at yahoo.com
Tue Oct 14 10:57:40 EDT 2003

On Tuesday 14 October 2003 04:46 pm, Guido van Rossum wrote:
> I'm not sure whether the defaults should cater to the extreme
> performance cases or to the smaller cases; I expect that the latter
> are more common, and people who are sorting truly huge lists should
> read the manual if they care about performance.  But that's just me.

I think your general philosophy on "defaults cover normal cases" is part of
what makes Python so good, so, if it's just you, that need not be a bad 
thing;-).  However, it seems to me that, in a normal case (sorting a
smallish number of easily comparable thingies), whether the indices are
or are not added to the decoration is not going to make an enormous
difference either way.  So, maybe we should focus on two slightly less
normal cases where performance or correctness may be impacted:

-- if we're sorting a huge list of easily comparable thingies then the
   overhead of adding so many indices to the decoration might hurt

-- if we're sorting a list of expensive-to-compare thingies (e.g. dicts)
   or non-comparable thingies, the indices (or something, but might
   as well be the indices, it seems to me) are needed in the
   decoration (except in the special cases where all keys can be
   guaranteed to differ, of course) -- whether the list is huge or not

This, plus your indication that only people sorting truly huge lists
should have to read the manual, suggests to me that defaulting
to decoration-with-indices (perhaps with an option to omit the
indices) might be a preferable chocie.


More information about the Python-Dev mailing list