using python from c/c++

Michael Chermside mcherm at mcherm.com
Fri Jun 10 15:56:15 EDT 2005


alexandr writes:
> Is it possible to create a library from my python module that can be
> used from c/c++ application?

Yes... the only question is how difficult it is.

The basic idea is that you create a library containing Python that
contains a hard-coded copy of your python script (or which reads it
from a file). The basics of doing this are described here:

     http://docs.python.org/ext/ext.html

... it's not too difficult, but it's certainly not automated.

Of course, there's not much gain over simply invoking the python
interpreter with the correct command line options... the "unix way"
(programs invoking other programs as command line utilities) is
very powerful.

What would be quite nice would be a sort of inverse to SWIG... a
tool to mechanically create C wrappers around a Python program. I
haven't heard of such a beast, but perhaps someone else will write
in to point one out.

-- Michael Chermside




More information about the Python-list mailing list