A faster Python?, Python compiler, Dylan,...

Siegfried Gonzi siegfried.gonzi at kfunigraz.ac.at
Thu Apr 4 03:52:38 EST 2002


Jan Kybic wrote:

> Great, I am becoming even more impressed. However, the main criticism
> remains: You have to code your function twice, first in Python for
> prototyping, then in C. But I agree that weave saves you a lot of
> work.

This can become a burden; especially if one has to code every day some
small functions in Python first and then in C or C++. But isn't it
sometimes a cost/benefit question? If you have a problem where you know
in advance that it will involve heavy duty array access in loops (and
your experience gained before tell you that Python slows down
remarkably), wouldn't it be wise to implement the function in C or C++
from the start on?

I can imagine that in complicated programs it is not always clear what
parts should become exposed to some tuning and what parts not. And the
often strained panacea: "Code in Python and your profiler will tell you
where the weakness lies", can become an obstacle in the long run. 

You are not the first who complained the speed of environments like
Matlab/IDL... I once red a commentar that one was tired of waiting more
then one day in Matlab of an execution result. He then rewrote the
simulation in Fortran 90 and everything went right in about 1 hour or
so.

But you should take into account that Python handles C interfaces very
well. I am not sure how you just use your Python; whether you use Python
only in combination with Numeric and not with a
plotting/image-processing library. I say this in the light of your
possible contemplation to give OCaml a try:

- Is it easy in OCaml to link to a plotting library (e.g. DISLIN)?
- Are there any numerical libraries available (e.g. Numeric in Python)?
- Can you read and handle binary files?
- No joke: Can you write a numer in a specific format to a file (e.g. in
Python "fix()")?; try it in Clean

If your simulation takes always hours then it is not a tradegy to save
the results to a file and consult a plotting program; but if you always
work in the range of seconds and minutes and want to plot your results
in an interactive mode then it can be awkward to work simultaneously
with two or three different programs.


S. Gonzi



More information about the Python-list mailing list