c++boost.gif (8819 bytes)
The Boost Python Library (Boost.Python)

Synopsis

Use the Boost Python Library to quickly and easily export a C++ library to Python such that the Python interface is very similar to the C++ interface. It is designed to be minimally intrusive on your C++ design. In most cases, you should not have to alter your C++ classes in any way in order to use them with Boost.Python. The system should simply ``reflect'' your C++ classes and functions into Python. The major features of Boost.Python include support for:

among others.

Supported Platforms

Boost.Python is known to have been tested against Python 2.2.1 using the following compilers:

Note that pickling doesn't work with Python 2.2 due to a core language bug. This is fixed in 2.2.1.

Boost.Python has also been used with other versions of Python back to Python 1.5.2. It is expected that the older Python releases still work, but we are not regularly testing for backward compatibility.

Credits

Table of Contents

  1. A Brief Introduction to writing Python extension modules
  2. Comparisons between Boost.Python and other systems for extending Python
  3. A Simple Example
  4. Exporting Classes
  5. Overridable Virtual Functions
  6. Function Overloading
  7. Inheritance
  8. Special Method and Operator Support
  9. A Peek Under the Hood
  10. Building an Extension Module
  11. Pickle Support
  12. Cross-Extension-Module Dependencies
  13. Wrapping Enums
  14. Pointers and Smart Pointers
  15. Internal Data Structures

Documentation is a major ongoing project; assistance is greatly appreciated! In the meantime, useful examples of every Boost.Python feature should be evident in the regression test files test/comprehensive.[py/hpp/cpp]

Questions should be directed to the Python C++ SIG.

© Copyright David Abrahams 2001. Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

Updated: Apr 2002