suitability of python
Alan Meyer
ameyer2 at yahoo.com
Thu Nov 24 23:06:26 EST 2011
On 11/24/2011 07:31 AM, Rudra Banerjee wrote:
> Dear friends,
> I am a newbie in python and basically i use python for postprocessing
> like plotting, data manipulation etc.
> Based on ease of programming on python I am wondering if I can consider
> it for the main development as well. My jobs (written on fortran) runs
> for weeks and quite CPU intensive. How python works on these type of
> heavy computation?
> Any comment or reference is welcome.
>
I would expect that a language that compiles intensive math programming
to machine language will be much more than an order of magnitude faster
than a program that does the same thing by interpreting byte code.
If you study all of the Python math libraries I'm guessing you'll find
modules that do a lot, conceivably all, of what you want in compiled
machine language, but when held together with Python it may or may not
be as efficient as fortran. I'm guessing there's not much out there
that is as efficient as fortran for purely numerical work.
I think your division of labor using fortran for the CPU intensive math
parts and python for post-processing is a pretty good one. It takes
advantage of the strength of each language. In addition, it completely
separates the two parts so that they aren't really dependent on each
other. You can change the fortran any way you want without breaking the
python code as long as you output the same format, and of course you can
change the python any way you want. Programs in each language don't even
have to know that any other language is involved.
My only suggestion is to see if you can get a profiler to see what's
happening inside that weeks long running fortran program. You might
find some surprises. I once wrote a 5,000 line program that was slower
than I had hoped. I ran it through a profiler and it showed me that I
was spending more than 50 percent of my time on one single line of my
code that called a simple library routine ("strcpy"). I wrote the
simple library routine inline instead adding just a few lines of code.
It cut the total execution time of the whole program in half.
Alan
More information about the Python-list
mailing list