How do I create extensions to Python in C?

Lyle Johnson jlj at cfdrc.com
Wed May 24 10:02:21 EDT 2000


Ryan,

You should start with the very good online documentation on this very
subject; refer to it as writing a Python extension if you want to use
the local jargon ;) The official docs for this are here:

	http://www.python.org/doc/current/ext/ext.html

I would like to be able to point you to some good books which address
this topic, but the fact is there aren't that many. Mark Lutz's
"Programming Python" covers it pretty well, and despite the book's "age"
most or all of the information on this topic is still up-to-date.
Another book, "Internet Programming with Python" (by Aaron Waters,
Guido, others?) had some material on extending Python but it was a
little sketchy. I think this one is now out-of-print but you may be able
to find it on-line somewhere.

Once you understand the basic concepts, you should check out SWIG, a
freely available tool which helps to automate a lot of the process and
lets you focus on the application itself. SWIG's home page is here:

	http://swig.sourceforge.net


If you're just wrapping basic C function calls, SWIG will do about 90%
of the work for you. I am a big fan of SWIG, as I suspect are many
people on this mailing list.

Hope this helps,

Lyle


Ryan Donahue wrote:
> 
> I new to python and would like to use it to call some C functions.  How do I
> do this.
> 
> Ryan Donahue ryan at velara.com



More information about the Python-list mailing list