Followup-To: comp.lang.scheme

"Xah Lee" <[EMAIL PROTECTED]> writes:

> Since this is frequently used, Python provides a somewhat shorter
> syntax for it, by specifying the column used as the ordering “key”.
[...]
> Because Python's implementation is not very refined , this specialized
> syntax is actually much speedier than the general form “lambda x, y:
> cmp(x[1],y[1])”. It is a burden on the programer to always use the
> “key” syntax idiosyncrasy if he is sorting a large matrix.

It's not only clearer for a human, but also faster in all good
implementations of all languages which support that, except when the
ordering function is very simple. It's called Schwartzian transform
and I wish more language designers and programmers knew about it.

http://en.wikipedia.org/wiki/Schwartzian_transform

I urge future SRFI authors to include it. The withdrawn SRFI-32 for
sorting didn't do that, and I can't find any other SRFI which deals
with sorting.

-- 
   __("<         Marcin Kowalczyk
   \__/       [EMAIL PROTECTED]
    ^^     http://qrnik.knm.org.pl/~qrczak/
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to