Why is Python popular, while Lisp and Scheme aren't?

Jacek Generowicz jacek.generowicz at cern.ch
Mon Nov 11 03:31:26 EST 2002


Fernando Pérez <fperez528 at yahoo.com> writes:

> Would you care to elaborate a bit? I'm honestly interested.

Sure, but I have approximately 0 time at the moment. If you want to me
to give any more details than I do, you will probably have to wait a
week or so ...

> Please keep in mind that I:
> 
> - know next to zero about lisp
> - have a pretty solid scientific computing background (I see you're
>   from CERN, I do lattice qcd).
> 
> So please be gentle on the lisp, which is what I'm interested in
> learning about, but don't pull any punches on the numerics. I want
> to know _specifically_ what kinds of transformations you were able
> to perform to enhance the performance of your numerical code.

First of all, let me say that I did nothing that I could not have done
by hand, except that given the number of (complicated) functions
involved, it would have taken a long time to do it that way, and I
would, undoubtedly have made many mistakes along the way. The macro
let me do this quickly and confidently ... and if anyone gives me such
a bunch of functions again, I can apply the optimization instantly.

Here goes ...

Mostly, we were interested in "the big function". This was built out
of calls to other functions, which were, in turn made up out of calls
to other functions etc.

Now, it was clear that the "auxiliary" functions were being called
very many times, with the same arguments, each time "the big function"
was being calculated. Memoizing would have been one obvious approach,
but I knew that at least one argument of "the big function" (TBF) was
monotonically increasing throughout my run ... so the memo would
mostly contain values which I knew I was never going to need again.

So I used the following caching scheme.

- Get the macro to collect all the names of the functions used in
  calculating TBF, by extracting them from the function definitions.

- Create cache variable names corresponding to those function names
  (Lisp separates namespaces for values and functions, so these names
  could be identical to the function names)

- Create new functons by replacing all calls to the cached functions
  with references to the cached variables.

- I made the new-cache referencing functons closures over the shared
  cached values, just to keep the latter from interfering with
  anything else, but that's a minor detail.

As I said, not really profound, but for a quick hack the result was
really satisfying.

I can imagine that you could put """ """ around your Python
definitions, do something similar by processing the resulting string,
and then eval it ... but it sounds far too painful to try.

> I have a question for you (keeping in mind what I said above about
> my background in HEP, moving these days towards algorithm
> development). Could you try to outline what things someone like me
> would benefit from in Lisp?

> I'd very much appreciate an overview of this by you or anyone else
> with a good lisp background.

I would not consider myself to have a "good lisp background". But I'd
be happy to try to make constructive suggestions, and maybe give you
some pointers ... but please allow me to postpone this for a week or
so, as I would not be able to make a sensible contribution with my
current time constraints.

Jacek.



More information about the Python-list mailing list