making my extensions work together

Katriel Cohn-Gordon katriel at katriel.co.uk
Thu Aug 4 10:18:38 EDT 2011


Wrap your 3rd party library with a Python interface module, and run all
calls from foo and goo through your interface.

On Thu, Aug 4, 2011 at 2:48 PM, Mathew <myeates at jpl.nasa.gov> wrote:

> more info.  I have a large 3rd party library with a function that looks
> like
> this
> void dumbfunc() {
> static int statevar=0;
> ++statevar;
> if (startvar ==3) printf("I have been called 3 times\n");
> }
>
> and I have 2 extensions, foo,py goo.py,created with SWIG, and the both make
> calls to dumbfunc. In creating the extensions, I linked to the 3rd party
> library.
>
> The behavior I want to see is
> >foo.dumbfunc()
> >goo.dumbfunc()
> >goo.dumbfunc()
> I have been called 3 times
>
>
> "Chris Angelico" <rosuav at gmail.com> wrote in message
> news:mailman.1880.1312441742.1164.python-list at python.org...
> > On Thu, Aug 4, 2011 at 2:19 AM, Mathew <myeates at jpl.nasa.gov> 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
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110804/10bd13cf/attachment-0001.html>


More information about the Python-list mailing list