Author image

Pybind 11 Tutorial


Pybind11 is a lightweight header only library that exposes c++ types in Python. 8k lines entire library. 5k LOC core codebase. You can use it to extend python with C/C++ written python extensions - similar to CPython, but in a much easier and up-to-date method. Alternatively you can embed the python interpreter in C++ allowing for python scripting in a C++ application. It can work both ways, it's not particularly hard and you basically get to marry the Beauty and the Beast together (and C++ is not the beauty..).

Tip:

If you don't have a python distribution installed on your system you can extract the python36.zip and python36.dll from the pybinding\x64\Debug\python-3.6.6-embed-amd64.zip file and place them on the same directory as the output executable. They will work exactly the same.

pybind_module is a static library project...

1