Loading C extension from memory

M

mk

Hello,

I wonder if there is a way to load C extension from in-memory object,
not from the file on the disk?

I'm asking bc I would like to download C extensions over network and
load them into Python interpreter (without storing the C extension in
file on the disk).

I googled for this but there appear only methods of loading compiled
Python (bytecode) modules.

Regards,
mk
 
M

Martin v. Loewis

I wonder if there is a way to load C extension from in-memory object,
not from the file on the disk?

I'm asking bc I would like to download C extensions over network and
load them into Python interpreter (without storing the C extension in
file on the disk).

I googled for this but there appear only methods of loading compiled
Python (bytecode) modules.

First, it depends on your operating system. None of the standard
operating systems supports loading shared libraries from memory; they
all need a file name.

Of course, your operating system may provide support for RAM disks. So
if you store the extension onto a RAM disk, you can load it from there -
from memory.

It may be possible to extend the Python interpreter to not rely on
shared libraries anymore for extension modules. Such an interpreter
likely wouldn't use standard shared libraries anymore, so you might
then have to recompile the extensions to make them loadable from memory.
However, it also might be possible to reimplement the shared library
loader of the operating system, in which case you could then run
regular extension modules directly from memory.

Regards,
Martin
 

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
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top