[PYTHON MATRIX-SIG] Calling all extensions...

Konrad Hinsen hinsen@ibs.ibs.fr
Sun, 3 Nov 96 18:30:36 +0100


> This is a dirty, not so Python-like solution, but is there a better one
> for scientific computations. For heavy computations you need compiled
> functions, which you can
> generate on the fly, evaluating a interpreted function 10000 time for a
> computation
> is to slow. Any comments on that.

Good question. A while ago I tried the approach of implementing a
data type "numerical expression" that would pretend to be a numerical
data type and could therefore be passed to any Python code doing
numerical calculations. The result would be a compiled version of that
code (still using a bytecode interpreter, but with typed data objects
and no memory allocation overhead during evaluation) that would be
a callable Python object.

It never got finished, partly due to time restrictions. However, I
realised that this approach had a few problems:

1) The speedup would be significant only for complicated code or
   loops, but since Python's branching and looping constructs
   could not be used, the idea of profitably compiling ordinary
   Python code in this way is probably illusionary.

2) Python's implementation of comparisons made using this extension
   really messy for nontrivial application.

3) For really CPU intensive calculations the stack-based evaluation
   engine was still too slow.

Nevertheless, I still think that some compilation method not requiring
to run the C compiler would be nice as an intermediate step. Not
everyone knows C, and not all systems support dynamic libraries, without
which the idea of just-in-time compilation doesn't make sense.

On the other hand, an easy way to interface to existing C and Fortran
functions would obviously be nice as way. "Easy" would ideally mean an
approach that can be used by someone who does not know C and/or Fortran.
Unfortunately I don't have any good solution at hand...

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-76.88.54.94
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais
-------------------------------------------------------------------------------

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================