MATLAB2Python

John J. Lee jjl at pobox.com
Thu Apr 29 17:57:36 EDT 2004


Sarge <sarge at arena.invalid> writes:

> > I have found numerous cases where Python programs run 10-100
> > times slower or more than a comparable Fortran 95 program. 
> 
> Uh-oh. This is not fine.
> I want to switch to py in order to achieve more flexibility 
> especially in the areas of GUIs, distributed computing, and oo-
> programming. But I don't want my programs run 100 times slower!

Don't mean to sound grumpy, but anybody who takes a bald statement
like that you quote above as meaningful, without thinking about what
it means, deserves what they get.


> Is it possible to integrate some fortran compiled routines in order 
> to speed up the more time-consuming steps?

Who doesn't, in this field?

Despite the fact that one often writes more lines of Python code than
of Fortran / C / C++, many apps that do this kind of work can be
regarded, for the purposes of CPU-efficiency, to be a bunch of Fortran
/ C / C++ code being driven by Python.  The idea is that you do the
heavy lifting with Fortran, wrap it (as SciPy does, for example), and
then solve your problem using Python, thus getting the best of both
worlds.  Exactly what you need to wrap to achieve acceptable
performance, is a "how long is a piece of string" question, which is
why the quote about '10-100' times is close to meaningless if
unqualified.

Lots of people have heavy numerical applications that they've written
mostly in Python.  This state of affairs is thanks to the work of many
clever people who've written good Fortran libraries and compilers, of
course.  And maybe you'll be unlucky and have to write a relatively
large amount of code in Fortran.  Who cares?  Are you going to write
*everything* in Fortran and work twice as hard as a result?  Maybe, if
you really care as much about performance as most people mistakenly
think they do <wink>.


> P.S. I have already tried Fortran95 for a while, but I found it's a 
> very old-fashioned language, more than Matlab itself, I didn't like 
> it very much.

Good luck <wink>


John



More information about the Python-list mailing list