This is an old copy of the Python FAQ. The information here may be outdated.

How do I interface to C++ objects from Python?

Depending on your requirements, there are many approaches. To do this manually, begin by reading Extending and Embedding the Python Interpreter (dead link). Realize that for the Python run-time system, there isn’t a whole lot of difference between C and C++ — so the strategy of building a new Python type around a C structure (pointer) type will also work for C++ objects.

If you don’t want to work at the Python C API level, you can use tools like Pyrex and SWIG. The former lets you write Python-like code for the interface, the latter uses special interface specifications to generate bindings for Python as well as several other languages.

There are also a number of more specialized tools available for C++, including SIP (dead link), CXX, Boost, and Weave (dead link).

CATEGORY: extending

 

A Django site. rendered by a django application. hosted by webfaction.