Re: importing modules written in C - how?

Steven Miale (
Sat, 14 May 1994 11:29:13 -0500

In article <>,
Steven D. Majewski <> 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

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

ld SUIT_Cmodule.o $SUIT/lib/
$SUIT/lib/ /lib/

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.)


Steven Miale - | Don't blame me - 
Indiana University, Bloomington, IN  | I voted Libertarian.