[Python-Dev] _PyImport_LoadDynamicModule questions

Martin v. Loewis martin@v.loewis.de
30 May 2002 23:35:08 +0200

Guido van Rossum <guido@python.org> writes:

> > However, I still think that people creating --enable-shared
> > installations are misguided: You gain nothing (IMO), and you lose a
> > number of benefits:
> Do you understand why people have always been asking for this?  Are
> they all misguided?  It really is a FAQ (3.30).  Why?

People give various reasons:

- (from #400938): "Using a shared library should have an advantage if
  you're running multiple instances of Python (be it standalone
  interpreter or embedded applications)."
  This is nonsense, of course: the interpreter executable is shared
  just as well.

- libraries should be shared (405931). There is often no further
  rationale given, but I believe "... because that saves disk space"
  is the common implication. Given that /usr/local/bin/python would be
  the only application of libpythonxy.so on most installation, this
  rationale is questionable.

- it simplifies embedding (with the variant "embedding is not possible
  without it"). Some people are simply not aware that a libpython.a is
  also installed. In 497102, James Henstridge argues that PyXPCOM
  mandates a shared libpython, as does gnome-vfs. He might have a case
  here, but I think a special-case shared library that exposes all
  Python symbols might be more appropriate.

- on the same topic, the PostgreSQL documentation claims that you
  cannot build PL/Python without a shared libpython. They admit that
  it might work to use the static library, and that it is just the
  fault of their build system to not support this scenario:

- For embedded applications, people also bring up "allows sharing at
  run-time" argument). In that case, it is factually true. However,
  even without a shared libpython, multiple copies of the same
  embedded executable (or shared library) will still share code.

- The Windows port uses a python DLL.

To summarize, it probably does have advantages for people who want to
embed Python in applications that are themselves shared libraries. I
think those advantages are outweighed by the problems people may get
with a shared libpython, and who never want to embed Python.

Just my 0.02EUR,