Home :: Tools :: Boost.Python

Boost.Python Examples and Tutorials

Introduction

Boost is a project to create open-source libraries for C++. There are a lot of nice tools available through Boost, one of which is Boost.python. Boost.Python provides seamless interoperability between C++ and Python. I have found it to be an extremely useful tool for scientific programming. Parts of a program that require more flexibility than speed can be written in Python, and critical portions can be coded in C++.

Tutorials and Examples

Unfortunately, the Boost.Python documentation is not written for beginners, and there is not a lot of help on other web sites. The mailing list is great, but a good mailing list does not replace good introductory documentation. I originally wrote and posted these examples on my blog, but I'm also putting them here so they are easier to find.

Extractor class example

Extractor class example

Using a raw C++ data structure in Python

Example using C++ data struture from Python

Mixing Python types in a Boost.Python list

Example of mixing Python types in a list

For further reference

Roman Yakovenko's web site features more information and examples of C++ and Python binding.