[C++-sig] When not to use static boost python library

Kun Hong kun.hong at uqconnect.edu.au
Thu May 13 16:22:52 CEST 2010

Nat Goodspeed wrote:
>> I guess
>> what the problem is should be that: another python extension, written 
>> in boost python,
>> cannot access the types and functions exposed in my current 
>> extension. I am not
>> clear why is it so, becaused it is exposed to the python interpreter 
>> already. If there are
>> two python extensions, both written in pure C, can't they access each 
>> other's type and
>> functions?
> Suppose you develop two different Python extensions, each statically
> linked with Boost.Python. The situation looks like this:
>             Ext1 | Boost.Python
>            /
> Python
> interpreter
>            \
>             Ext2 | Boost.Python
> You have two different copies of Boost.Python in memory at the same
> time. Presumably Boost.Python contains certain static data used to
> manage registering types to the Python interpreter. I guess the
> documentation is saying that if Ext2 tries to reference types defined in
> Ext1, it might confuse Boost.Python's static data.
> Contrast with dynamic linking:
>             Ext1
>            /    \
> Python           Boost.Python
> interpreter      /
>            \    /
>             Ext2
> Having a single copy of the Boost.Python static data eliminates the
> potential for confusion.

Thanks for the explantion. I think I understand better now. So I think 
as long
as I don't need to share this static registation information between two
boost python modules (in a sense, that these modules are self-contained and
just use python types), it is ok to use static boost python lib.

More information about the Cplusplus-sig mailing list