Question about scientific calculations in Python

Siegfried Gonzi siegfried.gonzi at kfunigraz.ac.at
Tue Mar 12 08:15:39 EST 2002


Martin Kaufmann wrote:


> Now my questions: Would it be best to
> 
> (a) write the whole program in C/C++ (I know only the basics of C but
> it would be a good "excuse" to learn it...)?
> (b) write the main program in Python but the heavy calculations in C
> (I played today with scipy.weave -- the speed is much better but I
> didn't really understand what I was doing...)?
> (c) program it in Python and don't care about speed (or buy a new
> workstation...)?

I once did a similar project in Yorick. It was not aimed at diffraction
patterns for electrons, but I have calculated the Fresnel-integral and
Zernike-polynomials via the FFT for a 1024x1024 grid in order to test
the diffraction pattern of a telescope. Yorick worked fine and I could
made some nice postscript outputs.

Projecting this experience to Python. I would assume (but without any
detailed study) that Python in  combination with the numeric library
will serve you very well. But it depends whether you can use a
straightforward algorithm (like the FFT) or you must solve your own
integral.


> Are there any libraries or other resources that would help? I used the
> Scientific Python library for the histogram but it was much slower
> than my DIY approach.

How much slower? A performance penalty of 100 would be of great concern;
a factor of 5 should not mind you (but this is my personal view). Okay,
if you have to wait in C or C++ 1 hour then even a factor of 5 is
somewhat bothersome.


Regards,
S. Gonzi



More information about the Python-list mailing list