<div class="gmail_quote">Wrap your 3rd party library with a Python interface module, and run all calls from foo and goo through your interface.</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Thu, Aug 4, 2011 at 2:48 PM, Mathew <span dir="ltr"><<a href="mailto:myeates@jpl.nasa.gov">myeates@jpl.nasa.gov</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">more info.  I have a large 3rd party library with a function that looks like<br>
this<br>
void dumbfunc() {<br>
static int statevar=0;<br>
++statevar;<br>
if (startvar ==3) printf("I have been called 3 times\n");<br>
}<br>
<br>
and I have 2 extensions, foo,py goo.py,created with SWIG, and the both make<br>
calls to dumbfunc. In creating the extensions, I linked to the 3rd party<br>
library.<br>
<br>
The behavior I want to see is<br>
>foo.dumbfunc()<br>
>goo.dumbfunc()<br>
>goo.dumbfunc()<br>
I have been called 3 times<br>
<br>
<br>
"Chris Angelico" <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> wrote in message<br>
news:mailman.1880.1312441742.1164.python-list@python.org...<br>
<div class="im">> On Thu, Aug 4, 2011 at 2:19 AM, Mathew <<a href="mailto:myeates@jpl.nasa.gov">myeates@jpl.nasa.gov</a>> wrote:<br>
</div><div class="im">>> I have 2 extensions and they both access a function in a (static)<br>
>> library.<br>
>> The function maintains state information using a static variable.<br>
><br>
</div><div class="im">> If your extensions are DLLs and they're both linking to the same<br>
> static library, you should have two independent copies of that library<br>
> - which would mean they don't interfere with one another. That's why<br>
> the other extension doesn't see the change, and normally this is the<br>
> correct and desired behaviour.<br>
><br>
> Having the two be aware of each other is potentially very messy. As<br>
> Stefan suggested, making one depend on the other would be a lot<br>
> simpler. Alternatively, there may be ways to have the two extensions<br>
> share data through Python itself. What are you looking to accomplish?<br>
><br>
> ChrisA<br>
<br>
<br>
--<br>
</div><div><div></div><div class="h5"><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>