Fortran vs Python - Newbie Question

Erik Johnson nobody at invalid.com
Mon Mar 26 12:59:46 EDT 2007


<Nomad.C at gmail.com> wrote in message
news:1174915232.414568.197250 at p15g2000hsd.googlegroups.com...
> OK...
> I've been told that Both Fortran and Python are easy to read, and are
> quite useful in creating scientific apps for the number crunching, but
> then Python is a tad slower than Fortran because of its a high level
> language nature, so what are the advantages of using Python for
> creating number crunching apps over Fortran??
> Thanks
> Chris

    So, after reading much of animated debate here, I think few would
suggest that Python is going to be faster than FORTRAN when it comes to raw
execution speed. Numeric and SciPy are Python modules that are geared
towards numerical computing and can give substantial performance gians over
plain Python.

    A reasonable approach (which has already been hinted at here), is to try
to have the best of both world by mixing Python and FORTRAN - doing most of
the logic and support code in Python and writing the raw computing routines
in FORTRAN. A reasonable approach might be to simply make your application
work in Python, then use profiling to identify what parts are slowest and
move those parts into a complied language such as FORTRAN or C if overall
performance is not fast enough.  Unless your number crunching project is
truly massive, you may find that Python is a lot faster than you thought and
may be plenty fast enough on it's own.

    So, there is a tradeoff of resources between development time, execution
time, readability, understandability, maintainability, etc.

    psyco is a module I haven't seen mentioned here - I don't know a lot
about it, but have seen substantial increases in performance in what little
I have used it. My understanding is that it produces multiple versions of
functions tuned to particular data types, thus gaining some advantage over
the default, untyped bytecode Python would normally produce. You can think
of it as a JIT compiler for Python (but that's not quite what it is doing).
The home page for that module is here:  http://psyco.sourceforge.net/

Hope that help,
-ej





More information about the Python-list mailing list