Python/SWIG: Namespace collisions in multiple modules.
schiotz1 at yahoo.com
Thu May 18 11:44:30 EDT 2000
Dear Python and SWIG gurus,
I am converting many of my C programs to Python modules using SWIG,
and am having two related problems.
1) How do I prevent namespace collisions if several modules contain
functions with the same name?
2) If the Python executable and several extension modules are using
the same library, how do I make sure they do not get separate copies
of it? The library is apparently using global data.
I previously had two (slightly) different functions with the same name
in two modules, that cause a coredump when I tried to use both modules
in the same Python script. I changed the name of the function in one
module, but this may happen again with functions (in particular
library functions) where I cannot change the name.
I am having problems with the MPI library (Message Passing Interface,
a library for parallel programming).
There is a complication with the this library: the initialization
function MPI_Init(&argc, &argv) MUST be called before the program
looks at its arguments. This means that it cannot be done in a module
imported by a Python script, as the python executable has to look at
its arguments to figure out what script to load. I have built a
modified Python executable which calls MPI_Init() just before calling
This works on the Compaq Alpha machines, and it worked under a
previous version of AIX, but with the new version of AIX (and a new
version of the MPI library) the extension module and the python
executable apparently get completely distinct versions of the MPI
library, so the extension module believes that MPI has not been
initialized, and crashes. Any suggestions? Can I somehow load the
entire MPI library into the Python executable and somehow be sure that
it is not linked into the extension modules as well?
Jakob Schiotz, CAMP and Department of Physics, Tech. Univ. of Denmark,
DK-2800 Lyngby, Denmark. http://www.fysik.dtu.dk/~schiotz/
This email address is used for newsgroups and mailing lists
(spam protection). Official email: schiotz @ fysik . dtu . dk
When spammed too much, I'll move on to schiotz2 at yahoo.com
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
More information about the Python-list