Mixing Python and C: any easy way?

Alan James Salmoni alan_salmoni at yahoo.com
Thu Jan 16 10:27:10 EST 2003


You may be interested in Weave which is part of the SciPy package
(http://www.scipy.org/site_content/weave) - it allows C++ code to be
included into Python code. I'm not sure if it is exactly what you
want, but maybe it is suitable for your purposes as it doesn't require
much of an interface. It works on Linux and Windows so far.

Alan James Salmoni
SalStat Software: http://salstat.sunsite.dk

Carl Bevil <carl_bevil at yahoo.com> wrote in message news:<CFN376368443311343 at news.mindspring.com>...
> Hey folks.  I'm on a small team of programmers developing a project over a 
> period of several months.  We normally code in C++, but are thinking it would 
> be nice to do part of the development in a scripting language such as Python.  
> The nature of our application is still going to require that large chunks of 
> the app still be done in C++.
> 
> So I've been looking into ways to easily interface the two languages.  The 
> only thing I've turned up so far is SWIG.  Unfortunately it doesn't seem to be 
> as automated as I'd like.  It appears that you have to create a special 
> interface file for every C++ header you want to access from Python.  There may 
> be many headers containing complicated objects in our project, and I 
> anticipate creating interface files would be a lot of work, and would turn 
> into a maintenance problem.  Maybe someone out there has been in a similar 
> situation and can tell me whether this is a pain or fairly easy?
> 
> 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.
> 
> 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?  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?
> 
> Thanks!
> 
> Carl




More information about the Python-list mailing list