[Matrix-SIG] performance hit in c extensions

hinsen@dirac.cnrs-orleans.fr hinsen@dirac.cnrs-orleans.fr
Fri, 1 Oct 1999 15:21:08 +0200


> I have sucessfully written wrappers for most of my C code so
> I can call the modules directly from python. Unfortunately,
> it *appears* that the code executes about 50% slower (I haven't
> actually timed it) when called from python versus being 
> called from the command line. I would not have thought
> there would be any performance impact. 

I could imagine two reasons:

- Different compiler options. Did you use full optimization to compile
  the extension modules? The Makefile.pre.in mechanism will give you
  the same options as were used to compile Python itself, which is not
  always the optimum.

- Calling overhead. If your C routines run only for a short time,
  the Python initialization and calling overhead might be significant.

In case of doubt, a profiler will tell you all you want to know
(and probably quite a bit more).

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------