shared lib from python code?

G

Gabriel Rossetti

Hello everyone,

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?

Thank you,
Gabriel
 
P

Paul Rubin

Gabriel Rossetti said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,005
Latest member
ChasityFan

Latest Threads

Top