pybind11: Seamless C++11+ Interop for Python
pybind11 is a lightweight, header-only C++11 library specifically designed for creating Python bindings to C++ code. It leverages compile-time introspection and C++11 features to expose C++ types and functions to Python and vice-versa with minimal boilerplate. It handles complex C++ constructs like classes, inheritance, exceptions, and overloaded functions, and offers direct support for NumPy arrays.
The top 3
- pybind11's Genesis: A Modern Successor to Boost.Python: Created by Wenzel Jakob, pybind11 emerged to offer a lighter, header-only C++11 solution, addressing Boost.Python's heavy dependency burden and complex, macro-heavy syntax. [3, 11, 13]
- Top 3 pybind11 Advantages Over Boost.Python: pybind11 offers significantly faster compilation and smaller binary sizes (e.g., 5.8x faster compile time, 5.4x smaller binaries for PyRosetta), a header-only design, and a cleaner, more modern C++ API compared to Boost.Python. [1, 3]
- Major Projects Powering Up with pybind11 Integration: Leading projects like PyTorch and other machine learning frameworks, alongside scientific computing libraries such as NumPy and SciPy, extensively use pybind11 for high-performance C++ interoperability. [6, 9]
Sources
Open the full topic