libpython as a shared library?

Quinn Dunkan quinn at lira.ugcs.caltech.edu
Sat Jun 8 23:51:12 EDT 2002


On 06 Jun 2002 10:37:42 +0200, Martin v. Löwis <loewis at informatik.hu-berlin.de>
wrote:
>Gregor Hoffleit <gregor at hoffleit.de> writes:
>
>> 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!
>
>Can you elaborate a bit what you measured to get that speed difference?
>
>If it involves startup time, the time for locating libpython surely
>involves part of startup time. Also, it might be necessary to perform
>many relocations to libpython at run time that might not be necessary
>for the application.

I hope 2.3 doesn't dynamicly link libpython by default.  Not really because
of the performance issue, if there is one, but that it seems silly to introduce
the annoyance and fragility of shared libraries when all it would do is save
a few K for programs which embed python (and I have yet to see any of those).



More information about the Python-list mailing list