[Python-Dev] Problems with Python's default dlopen flags

Andrew MacIntyre andymac@bullseye.apana.org.au
Sun, 5 May 2002 11:40:09 +1100 (edt)


On Sat, 4 May 2002, David Abrahams wrote:

> Did you misread my suggestion? I didn't say that RTLD_GLOBAL should be
> the default way to load an extension module, only that there should be a
> way for the module itself to determine how it's loaded.

I don't want to rain on your parade, but some reasearch into dynamic
linking loaders proves distressing:-

- some always link globally (Windows, OS/2 as I understand);
- the others require explicit specification of the method (global/local).

The ones that give you the choice require you to specify the method when
the first reference to the shared object is made.  If you want to change
the mode, you have to dereference all entry points and unload the SO
before having another go.  This turns out to be nightmarish.

In addition to the shim module elsewhere referred to, I think that you
might also be able to leverage a pure Python wrapper to import the other
modules (in effect a specialised version of the import hook wrappers
available.

Another apprach is to use a "core" module which links all the necessary
bits and provides a vector of entry points which can be retrieved via a
Python API call (I forget which relatively common module I've seen which
does this).

--
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac@bullseye.apana.org.au  | Snail: PO Box 370
        andymac@pcug.org.au            |        Belconnen  ACT  2616
Web:    http://www.andymac.org/        |        Australia