[Python-Dev] Re: Python-Dev Digest, Vol 3, Issue 25

Peter Norvig pnorvig at google.com
Mon Oct 13 17:17:46 EDT 2003


I like "sort" better than "decorator"; I would also like "by", as in
sort(names, by=ages.__getitem__).

I would also advocate an optional reverse=False argument, so that

result = sort(names, reverse=True)

is equivalent to

result = sort(names)
result.reverse()



> Date: Mon, 13 Oct 2003 15:34:15 -0400
> From: "Raymond Hettinger" <raymond.hettinger at verizon.net>
> Subject: [Python-Dev] decorate-sort-undecorate
> To: <python-dev at python.org>
> Message-ID: <001f01c391c0$fcdb88a0$e841fea9 at oemcomputer>
> Content-Type: text/plain; charset="us-ascii"
>
> For Py2.4, I propose adding an optional list.sort() argument to support
> the decorate-sort-undecorate pattern.
>
> The current, pure Python approach to DSU is pure arcana.  It is obscure
> enough and cumbersome enough that cmpfunc() tends to get used instead.
>
> Built-in C support for DSU requires much less skill to use, results in
> more readable code, and runs faster.
>
> Raymond Hettinger
>



More information about the Python-Dev mailing list