[Python-Dev] decorate-sort-undecorate

Jeremy Hylton jeremy at alum.mit.edu
Wed Oct 15 15:11:30 EDT 2003

On Wed, 2003-10-15 at 14:42, Mark Russell wrote:
> I have a trivial wrapper function sortcopy() in my
> I-wish-these-were-builtins module:
> def sortcopy(vals, cmpfunc=None):
>     """Non in-place wrapper for list.sort()."""
>     copy = list(vals)
>     copy.sort(cmpfunc)
>     return copy
> I use this more often than list.sort(), because most of the time
> performance and memory use is not an issue and code using the in-place
> version is irritatingly verbose.  Maybe this is worth adding as a
> builtin, to satisfy the people that want a non in-place sort.

No.  This is so easy to write, we're all destined to write it again and
again <0.4 wink>.  I also use sort():

def sort(L):
    return L


More information about the Python-Dev mailing list