Python frontend to C++ code

Alex Martelli aleaxit at yahoo.com
Sun Sep 3 02:32:56 EDT 2000


<s_gherman at yahoo.com> wrote in message news:8osfjo$1ka$1 at nnrp1.deja.com...
> Hi. I've read in many places that Python is ideal for fast prototyping
> and for building a portable frontend to C/C++ code.
>
> I am a Python beginner but an experimented C++ programmer and I am
> considering building such a frontend. But I am not sure which are my
> options: I've read about embeding and extending Python (but both seem
> to request quite a lot of wrapping code, which doesn't sound to me
> like "fast prototyping").
>
> So, I'd like to ask you guys which are my options in this case?

I suggest you have a look at the very recent thread "SWIG to the
rescue".  With SWIG, you can wrap your C library in code that will
build and install a Python-usable module (.pyd) with an amount
of effort that can be reasonably small.

Wrapping code that uses advanced C++ stuff is more work, as SWIG
doesn't much support several such C++ constructs, such as templates
(assuming your API exposes them); but if that's what you need you
can try the CXX package (cxx.sourgeforge.net), which uses C++ to
greatly reduce the wrapping effort.  It's not as stable as SWIG, right
now, but it does work.

If you're on Win32, COM/Automation is yet another option; Python
works well with that on Windows platforms.  Corba (and SOAP, not
very mature yet) can be other options.

The fast-prototyping comes _after_ you're done with the wrapping,
of course -- when you use Python instead of lower-level code to
glue components in different ways, extend/tweak components, build
new ones.  That's where the productivity gains really come...


Alex






More information about the Python-list mailing list