[C++-SIG] Python calling C++ issues

Ian Searle ians at amc.com
Wed Dec 1 15:36:47 CET 1999


Ephi Dror wrote:
> 
> 
> Does anyone know how much Python is really  used  on Redhat Linux with the
> conjunction with C++, especially the direction of Python calling C++
> functions?

We are developing version 2 of a large application that will be centered
around Python with several large, complex C++ extensions.  The
application is targeted at embedded software developers and provides
visibility into their embedded target via source code instrumentation,
and analysis of the resulting "tag stream" as their target runs.  The
product is called CodeTEST (www.amc.com).  We have been shipping a
"reduced" version of this for a year now that allows customers to script
tests for source code coverage with great success.  The only reason I am
providing this information is to add some context, and hopefully, some
believability to the claims that will follow.  The only difference is
that we ship a python we build with the product, as we cannot depend
upon our customers to already have it installed.

We ship on Windows NT, Solaris, and soon Linux.  So, the answer to your
question is yes, we use Python to supply an interface to our C++
libraries. To date it works quite well on all platforms that we develop
on.  This is not to say there have been no difficulties.  But, they have
not been insurmountable, and the payoff for using Python is too great to
let a few annoyances impede progress.  Besides, to date most of our
problems have been centered around C++ itself.  Our C++ components make
heavy use of STL, and getting them to work with both VC++ and g++ can be
a challenge.  Mostly due to the inadequate STL shipped with VC++ 6.0.
 
> We have not given up yet but we are close. I would love to hear from the
> group that I am wrong. That I was just blind and simply did not get it.
> That calling C++ class from Python is really a piece of cake after all and
> especially on RedHat 6.1 Linux with standard  installation components.

I believe you are wrong. Calling a C++ class is not too difficult.  I
will take an extension I wrote recently, and pair it down to something
very simple.  I think the thing you missed in your simple example is not
creating a new type.  Trying to pass C++ object pointers around as other
things is not the best road to travel in my opinion.  If you extend
Python with a new type, you can do type checking on the self argument,
and make your extension more robust in the presence of other
programmers.

I will mail the sample extension to this list in a few hours.

> 
> Thank you all for helping us.
> 
> We hope to stay in the group and contribute in the future, but it all depend
> on what next for us in terms of using Python/C++.
> 
> Ephi.

-Ian Searle
 Engineering Manager
 Software Analysis Tools
 Applied Microsystems Corporation
 http://www.amc.com




More information about the Cplusplus-sig mailing list