Glue code

mackstann mack at incise.org
Thu Jun 12 17:57:15 EDT 2003


On Thu, Jun 12, 2003 at 09:15:30PM +0000, DB_RobertP wrote:
> What systems do people use to easily make C/C++ code visible to Python?
> I'm currently checking out Swig, but I've heard others mentioned. If
> anyone has any experience with these systems, could you recommend one to
> look into? Also, any other general pointers when trying to extend C/C++
> code to python sctipts would be greatly appreciated.

Swig is what we have been using on a new project I've been working on
(a scriptable window manager, kahakai.sf.net), and although I'm quite
into python, I don't know a lot of C or C++ so I haven't done much in
the way of the work with swig.  So, I can tell you that it has been
working well for us, but I can't provide much insight into the
intricacies of it, pros/cons, etc.

Here's the little I know:

If you're going about "extending" python (vs "embedding"), you basically
just create swig wrapper files for the C/C++ header files, compile a
shared object, and then all of your functions/classes/data/etc are
"translated" into python (or other language) extensions by swig,
transparently, compiled to a shared object, and then you just load that
up and work with it like a normal python module (or perl module, or what
have you).

Anyways, within a few days we had rough python integration, and now
after a couple weeks we have almost complete python integration.  So it
definitely isn't a gargantuan undertaking.

That's about the extent of what I know. :)

-- 
m a c k s t a n n  mack @ incise.org  http://incise.org
If you put garbage in a computer nothing comes out but garbage.  But
this garbage, having passed through a very expensive machine, is
somehow ennobled and none dare criticize it.





More information about the Python-list mailing list