Jon Harrop <j...@ffconsultancy.com> writes:
> You mean people use that pattern as a fast alternative in languages where
> user-defined functions are very slow, like Python and Mathematica?

It really doesn't matter whether the language is fast or slow--there
are going to be applications where calling the comparison function
multiple times per element is slower than calling it once per element
and storing the result.

Note the Haskell idiom (sortBy (compare`on`f) xs) is similar to DSU
but calls the comparison function multiple times.

Python 3.0 went overboard by actually removing the cmp argument and
requiring use of the key argument.  That requires various kludges if
the key is, say, a tree structure that has to be recursively compared
with another such structure.  Maybe then can bring back cmp someday.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to