Integrating Python into a C++ app

Axel Diener Axel.Diener at orsoft.de
Tue Jan 4 02:35:17 EST 2005



-----Original Message-----
From: Ben Sizer [mailto:kylotan at gmail.com]
Sent: Tuesday, January 04, 2005 2:14 AM
To: python-list at python.org
Subject: Integrating Python into a C++ app


I know the conventional wisdom is to write the whole app in Python and
only extend with C++ where speed is an issue, but I already have a
large C++ app that I'd like to add Python to. Ideally I'd rewrite the
whole app in Python but I don't have time to do that and maintain the
old system at the same time. So my next thought was to perhaps
integrate the two and slowly migrate modules and classes across from
C++ to Python. If it matters, the main reason I'm interested in doing
this is because I appreciate the productivity of Python and would like
to take advantage of that as I add features to the current code, to
reduce bugs and cut development time.

I've read a few good things in this group about Elmer
(http://elmer.sourceforge.net), but I'm not sure how simply that
accommodates calls in the reverse direction (from Python code back into
C++). Are there any other options that would require a minimum of
rewriting of code? Does anybody have any experience of such a project?
--
Ben Sizer


Even embedding Python in a C++ Application is an easy task. I work at such
an application since about five years. For the first steps in doing this I
advice you to study the source code of the modpython apache extension.
There you will see how embedding may be implemented. Bur embedding does not
work well without extending. For this part I use PyCXX from
http://sourceforge.net/projects/cxx/.

Axel Diener




More information about the Python-list mailing list