Bridging Python to C++ - and vice-versa
Jack Jansen
CWI
<Jack.Jansen@cwi.nl>
I found myself in need of good access to C++ functionality from Python. By "good" I mean: more than simply being able to call C++ routines or methods, but also the ability to subclass C++ baseclasses in Python, and subclass Python baseclasses in C++, similar to the functionality PyObjC provides when you need interoperability between Python and Objective-C.

The objective is tackled by extending the standard (but little known:-) bgen bridge to be able to parse C++ headers, teaching it about C++ objects, inheritance and callbacks and exposing the result as a Python extension module.

There are various other solutions that allow you to automatically generate Python interfaces to C++ libraries, but I could not find any that I really liked: most are lacking in functionality, such as bidirectional subclassing, some are bloatware, some are ugly. So in good open source tradition I decided to try and do better.

At the time of writing this abstract this is still work in progress, so the talk will focus more on the solutions chosen than on the actual tool, which is expected that the tool itself will be in the next Python distribution. For this reason the talk is geared more towards people who write extension modules and who are interested in how Python works internally than towards general Python users.


Jack Jansen, , http://www.cwi.nl/~jack




Last modified: Sun, 16 Oct 2005 20:50:27 +0200