About this project

pybind11 is a lightweight, header-only C++ library that enables seamless interoperability between C++ and Python. It is primarily used to create Python bindings for existing C++ code, exposing C++ types to Python and vice versa. The project was created as a smaller, self-contained alternative to Boost.Python, avoiding Boost's large dependency footprint by relying on C++11 features such as tuples, lambda functions, and variadic templates. The library supports mapping a wide range of C++ features to Python, including functions with custom data structures, instance and static methods, overloaded functions, attributes, exceptions, enumerations, callbacks, iterators, custom operators, inheritance, STL containers, smart pointers, and virtual method extension from Python. It also provides integrated NumPy support, automatic function vectorization over NumPy arrays, buffer protocol exposure for efficient data transfer, slice-based access, and pickle support for C++ types. pybind11 works with CPython 3.9+, PyPy3, and GraalPy through an implementation-agnostic interface. The library consists of only a few header files and requires no linking against additional libraries. Documentation is available at pybind11.readthedocs.io, with examples for setuptools, scikit-build, and CMake integration. The project is distributed under a BSD-style license and is available on PyPI and conda-forge.