shared lib from python code?

Paul Rubin http
Mon Feb 23 05:37:49 EST 2009


Gabriel Rossetti <gabriel.rossetti at arimaz.com> writes:
> I would like to know if it is possible to turn python code into a
> shared lib? I have several processes that use the same base code, and
> it seems like every process loads the "shared" code into memory. I
> would like it to be loaded once and shared, like a .so in linux or a
> .dll in windows and have the interpreters use the dared copy. Is there
> a way to do this?

I guess it's not completely inconceivable--Emacs used something called
unexec back in the day, that transmogrified part of its data segment
into the text segment and dumped it out as a runnable binary--but it
doesn't seem worth it nowadays, given how small your .pyc's are likely
to be relative to the size of memory.  If you're concerned about the
import overhead, maybe you can structure your program as a persistent
process instead of re-running it all the time.



More information about the Python-list mailing list