emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cl.el sort* efficiency


From: Juanma Barranquero
Subject: Re: cl.el sort* efficiency
Date: Sat, 23 Dec 2006 01:29:23 +0100

On 12/22/06, Kevin Ryde <address@hidden> wrote:

I noticed that cl sort* function calls the given :key function within
every comparison, which is not good if key extraction is a big slow
calculation.

[...]

The code below is an idea to build key results in an alist and sort
that.

You're implementing a Schwartzian Transform
(http://en.wikipedia.org/wiki/Schwartzian_transform) inside sort*,
which is kinda odd.

IMHO is the responsibility of the user of sort* to know whether
comparisons are going to be expensive and preprocess the data to help
in the comparison. You're doing an optimization at the wrong level:
perhaps I'm using it with so light a comparison function that your
method makes it more expensive...

Perhaps you could encapsulate your ST in a function and use it as a
wrapper for sort*.

                   /L/e/k/t/u




reply via email to

[Prev in Thread] Current Thread [Next in Thread]