Mixing Python and C: any easy way?

Paul Rubin phr-n2002b at NOSPAMnightsong.com
Wed Jan 15 23:42:44 EST 2003


Carl Bevil <carl_bevil at yahoo.com> writes:
> Thing is, I am hesitant to tell the other programmers on the team,
> "You have to learn a new language, which will make development
> faster, but you also have to create special SWIG files for every C++
> header you want to access from this new language, and make sure you
> keep these files up to date with changes you make in your headers,
> etc....".  We have a tight schedule (who doesn't?), so I'm worried
> about efficiency.

SWIG doesn't necessarily need those files if the interface is simple
enough--it can figure out a fair amount all by itself.

> Am I overreacting here?  And is there a better way to do this?  If
> not SWIG, then what can do this task?  Am I asking for the
> impossible?  

There's something called Boost Python but I haven't looked into it
much.  SWIG is primarily for interfacing to C.

> I've heard that Python is supposed to be good at interfacing with
> C/C++.  Can someone give me some pointers that will help me out here?

There's going to be a certain amount of glue required for interfacing
to any extension language.  It's just in the nature of extension
languages.  SWIG takes care of a lot of the hair for you but you
still have to deal with some.




More information about the Python-list mailing list