|
From: Nicola J. <nic...@gm...> - 2007-12-06 14:51:45
|
Hi all, I'm having a little problem with a project I'm working on. The starting point is a a big project where I have a series of swig files wrapped all in one cpp file and then compiled in one shot to get a single python module. The original .i file looks lke this: %module MyPythonProject %include a.i %include b.i %include c.i %include d.i <code> The compiled file is then linked to a shared library (MyLib.so) where a singleton derived class(MySingleton) is implemented. MySingleton has a private variable x and public get/set methods that I can use from a.i. When I change x, its value changes also in the objects wrapped in b.i,c.i and d.i. What I have tried to do is simply splitting my project in smaller modules: %module MyPythonProject %import a.i %import b.i %import c.i %import d.i <code> Compiling each file separately I get a.py, b.py , c.py, d.py and of course MyPythonProject.py. What I was expecting was that setting x using a.py, his value would be the same in all the other modules as well. What I get instead is that if x is changed in a.py it doesn't change in the other modules. Does this mean that MyLib.so is not shared by all the python modules but that each py uses is own instance of the library? Any idea how to get the singleton behavior right even with the splitted version of MyProject? Thanks Forward |