copysort patch, was RE: [Python-Dev] inline sort option

Mark Russell marktrussell at btopenworld.com
Mon Oct 20 17:11:02 EDT 2003


On Mon, 2003-10-20 at 19:22, Guido van Rossum wrote:
> But the argument that it wastes a copy still stands (even though
> that's only O(N) vs. O(N log N) for the sort).

That would be irrelevant in most of the cases where I would use it -
typically sorting short lists or dicts where the overhead is
unmeasurable.

> I'm still unclear why this so important to have in the library when
> you can write it yourself in two lines.

For little standalone scripts it gets a bit tedious to write this again
and again.  It doesn't take much code to write dict.fromkeys() manually,
but I'm glad that it's there.  I'd say list.sorted (or whatever it gets
called) has at least as much claim to exist.  

Mark Russell



More information about the Python-Dev mailing list