Re: importing modules written in C - how?

Steven Miale (smiale@cs.indiana.edu)
Sat, 14 May 1994 11:29:13 -0500

In article <199405140334.AA21703@elvis.med.virginia.edu>,
Steven D. Majewski <sdm7g@elvis.med.virginia.edu> wrote:
>If your system supports dynamic loading of object modules, and if
>your Python is built to support it, you can dynamically load .o
>( or on Sun, .so ) modules.

The file Doc/ext.tex gives all the necessary information.

Some other hints (for the Sun, at least):

- if two object files are required instead of one (for instance,
md5 wants md5module.o and md5c.o), then both need to be put
into the shared library:

ld md5module.o md5c.o -o md5module.so

You can also add .a and .so files. I now have the SUIT_C library
dynamic:

ld SUIT_Cmodule.o $SUIT/lib/libsuit.so.2.3
$SUIT/lib/libsrgp.so.2.3 /lib/libX11.so.4.10
-o SUIT_Cmodule.so

Making 3 libraries dynamic (rotor, md5, and especially SUIT) reduced
the size of the python binary from 525K to 400K. The .so files are about
20K larger than the combined size of the components. This still saves
disk space, because there is only one copy of the .so file, while
there are effectively three copies of the .o file (one plain, one
combined into libModules.a, and one combined into the executable.)

Steve

-- 
Steven Miale - smiale@cs.indiana.edu | Don't blame me - 
Indiana University, Bloomington, IN  | I voted Libertarian.