libpython as a shared library?

Gregor Hoffleit gregor at hoffleit.de
Thu Jun 6 03:25:01 EDT 2002


* Andrew MacIntyre <andymac at bullseye.apana.org.au> [020605 21:15]:
> On Tue, 4 Jun 2002, Gregor Hoffleit wrote:
> 
> > Debian has had libpython as a shared lib since a while. Recently, we got
> > a report that the performance of the shared version is dramatically
> > slower than the statically linked version (e.g. about 30%). I made some
> > pystone tests on different architectures of our GNU/Linux, and tried
> > different flags for building and linking the library (and different
> > Python versions), and in fact there seems a significant speed penalty
> > involved as soon as the interpreter is linked against the shared
> > library. The penalty has some correlation to the architecture, but it is
> > significant on all tested constellations.
> 
> A result of PIC code in the shared library?  I've not been motivated
> enough to try building a shared lib on FreeBSD.

If I compile the sources with -fPIC, but put them in a static library,
there's nearly no speed difference to non-PIC code in a static library.
My best guess is that the speed penalty is caused by the indirection
step that's necessary when calling routines from a shared lib; but then,
that's no real explanation for a loss of 30% speed!

That's why I would be interested in a few datapoints from other systems.

    Gregor





More information about the Python-list mailing list