[Python-Dev] decorate-sort-undecorate
Mark Russell
marktrussell at btopenworld.com
Wed Oct 15 14:42:47 EDT 2003
On Wed, 2003-10-15 at 18:52, Guido van Rossum wrote:
> > While we're hacking on [].sort(), how horrible would it be if we
> > modified it to return self instead of None?
>
> -1000. This is non-negotiable.
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.
Mark Russell
More information about the Python-Dev
mailing list