making my extensions work together

Mathew myeates at
Thu Aug 4 09:48:11 EDT 2011

more info.  I have a large 3rd party library with a function that looks like 
void dumbfunc() {
static int statevar=0;
if (startvar ==3) printf("I have been called 3 times\n");

and I have 2 extensions, foo,py,created with SWIG, and the both make 
calls to dumbfunc. In creating the extensions, I linked to the 3rd party 

The behavior I want to see is
I have been called 3 times

"Chris Angelico" <rosuav at> wrote in message 
news:mailman.1880.1312441742.1164.python-list at
> On Thu, Aug 4, 2011 at 2:19 AM, Mathew <myeates at> wrote:
>> I have 2 extensions and they both access a function in a (static) 
>> library.
>> The function maintains state information using a static variable.
> If your extensions are DLLs and they're both linking to the same
> static library, you should have two independent copies of that library
> - which would mean they don't interfere with one another. That's why
> the other extension doesn't see the change, and normally this is the
> correct and desired behaviour.
> Having the two be aware of each other is potentially very messy. As
> Stefan suggested, making one depend on the other would be a lot
> simpler. Alternatively, there may be ways to have the two extensions
> share data through Python itself. What are you looking to accomplish?
> ChrisA 

More information about the Python-list mailing list