Hi,
I am trying to hunt down the difference in performance between some raw C++ code and calling the C++ code from Python. My goal is to use Python to control a bunch of number crunching code, and I need to show that this will not incur a (big) performance hit.
This post includes a description of my problem, ideas I have for the cause, and some things I plan to try next week. If anyone knows the real cause, or thinks any of my ideas are way off base, I would appreciate hearing about it.
My C++ function (testfunction) runs in 2.9 seconds when called from a C++ program, but runs in 4.3 seconds when called from Python. testfunction calculates its own running time with calls to clock(), and this is for only one iteration, so none of the time is in the SWIG code or Python.
Both the C++ executable and python module were linked from the same object files, and linked with the same options. The only difference is that the Python module is linked with -shared, and the C++ code is not.
The computer is an Itanium 2. The code was compiled with the Intel Compiler, and uses the Intel Math Libraries. Python is version 2.2 (with little hope of being able to upgrade) from the Red Hat rpm install. When I link the C++ exe, I get some warnings about "log2l not implemented" from libimf, but I do not see these when I link the Python .so.
Some potential causes of my problems:
- linking to a shared library instead building a static exe.
- intel libraries are not being used when I think they are
- libpython.so was built with gcc, so I am getting some link issues
- can linking to python affect my memory allocation and deallocation in c++??
Some things I can try:
- recompile python with the intel compiler and try again
- compile my extension into a python interpreter, statically
- segregate the memory allocations from the numerical work and compare how the C++ and Python versions compare
--end brain dump
Dave -- http://mail.python.org/mailman/listinfo/python-list