Pybind11 2.6.1

pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. Its goals and syntax are similar to the excellent Boost.Python library by David Abrahams: to minimize boilerplate code in traditional extension modules by inferring type information using compile-time introspection.

Tags c++ python library embedded developers
License Public Domain
State stable

Recent Releases

2.6.112 Nov 2020 03:15 minor feature: py::exec, py::eval, and py::eval_file now add the builtins module as "__builtins__" to their globals argument, better matching exec and eval in pure Python. #2616. setup_helpers will no longer set a minimum macOS version lower than the current version. #2622. Allow deleting static properties. #2629. Seal a leak in def_buffer, cleaning up the capture object after the class_ object goes out of scope.#2634. pybind11_INCLUDE_DIRS was incorrect, potentially causing a regression if it was expected to include PYTHON_INCLUDE_DIRS (please use targets instead). #2636. Added parameter names to the py::enum_ constructor and methods, avoiding arg0 in the generated docstrings. #2637. Added needs_recompile optional function to the ParallelCompiler helper, to allow a recompile to be skipped based on a user-defined function. #2643.
2.6.022 Oct 2020 15:05 minor feature: Keyword-only arguments supported in Python 2 or 3 with py::kw_only(). #2100. Positional-only arguments supported in Python 2 or 3 with py::pos_only(). #2459. py::is_final() class modifier to block subclassing (CPython only). #2151. Added py::prepend(), allowing a function to be placed at the beginning of the overload chain. #1131. Access to the type object now provided with py::type::of() and py::type::of(h). #2364. Perfect forwarding support for methods. #2048. Added py::error_already_set::discard_as_unraisable(). #2372. py::hash is now public. #2217. py::class_ is now supported. Note that writing to one data member of the union and reading another (type punning) is UB in C++. Thus pybind11-bound enums should never be used for such conversions. #2320. Classes now check local scope when registering members, allowing a subclass to have a member with the same name as a parent (such as an enum). #2335. Error now thrown when __init__ is forgotten on subclasses. #2152. Throw error if conversion to a pybind11 type if the Python object isn't a valid instance of that type, such as py::bytes(o) when py::object o isn't a bytes instance. #2349. Throw if conversion to str fails. #2477. py::module was renamed py::module_ to avoid with C++20 when used unqualified, but an alias py::module is provided for backward compatibility. #2489. Public constructors for py::module_ have been deprecated; please use pybind11::module_::create_extension_module if you were using the public constructor (fairly rare after PYBIND11_MODULE was introduced). #2552. PYBIND11_OVERLOAD macros and get_overload function replaced by correctly-named PYBIND11_OVERRIDE and get_override, ing inconsistencies in the presence of a closing ; in these macros. get_type_overload is deprecated. #2325. The Python package was reworked to be more powerful and useful. #2433 build-setuptools is easier thanks to a new pybind11.setup_helpers module, which provides utilities to use setuptools with pybind11. It c
2.6.0rc111 Oct 2020 07:25 minor feature: ci: publish in two steps . Check if module file extension could be queried correctly. . Moving tp_class access, and consistent fully-qualified naming for PyP . . Allow raw unions without base classes in is_accessible_base_of. . : conda-forge patch. . Unify Python 2 3 py::module constructor, and make contructor with p . . Feat: parallel compiler. . /Check actual value when deregistering pybind11 instance. . Add unchecked_reference::operator() and operator to overload resolu . . Feat: vectorize functions with void return type. . ci: label PRs with changelog needed. . Update pr_merged.yml. . : ensure the GIL is held when copying a function.. . ci: labeler. . Refactor: import check as a common function. . Docs: odd spacing. . Refactor: module - module_ with typedef. . Buffer_info for ctypes buffers. . Docs: add std::valarray to docs/advanced/cast/stl.rst. . Chore: drop support for PyPy 7.3.1 and clean up old PyPy workarounds (. . : find_import didn't work properly for classic tools. . Fail on passing py::object with wrong Python type to py::object subcl . . Feat: py::prepend tag. . : PYBIND11_OBJECT required pybind11 namespace (regression). . Docs: minor cleanup. . ci: test on Windows 3.8 and 3.9 (mostly). . Docs: use sorted(glob()) in example . Test: hide segfault. . Check scope's __dict__ instead of using hasattr when registering clas . . Feat: deprecate public constructors of module_ class. . Docs: known. . ci: update PGI to 20.9. . : do not use abi::__forced_unwind with libc++, even with gcc inste . . ci: labeler. . Chore: bump to 2.6.0rc1. . : formatting. Refactor: simpler followup to #2569. . : allow cmake varibles from Python calls to be cached.
2.6.0b103 Oct 2020 10:45 minor feature: Begin working on next version . Allows users to specialize polymorphic_type_hook with std::enable_if. . Adding a default virtual destructor to Animal type in test_tagbased_p . . Utilize CMake's language standards abstraction when possible. . Document CMAKE_CXX_STANDARD. . Declare `operator==` and `operator!=` member functions const. . Change __init__(self) to __new__(cls). . Find library path to via glob command in /usr/lib/llvm- . . Change set_path to set_file. . Typo in sorted function call argument reverse. . Add is_final to disallow inheritance from Python. . Compilation with clang-cl. . Support keyword-only arguments. . Rename args_kw_only to kwonly. . Adding method names to cpp_function constructor calls in enum_base. . Propagate exceptions in sequence::size(). . Add AutoWIG to list of binding generators. . Revert "Change __init__(self) to __new__(cls)". . CI, prepare test on Python 3.9 beta. . Pytypes.h: docs generation. . Cmake: Expose `PYBIND11_TEST_OVERRIDE`. . Operators: Move hash check to before mutations, tweak whitespace. . Operators: Explicitly expose `py::hash(py::self)`. . Disable defining (v)snprintf as macro in modern Visual Studio. . common.h Mark entry point as "unused". . Compiler error with MSVC 17 and CUDA 10.2. . common.h Mark another entry point as "unused". . Deepcopy documentation. . Add lvalue ref-qualified cpp_function constructors. . Render full numpy numeric names (e.g. numpy.int32). . Render py::iterator/py::iterable as Iterator/Iterable in docstrings. . Render pybind11::array as numpy.ndarray in docstrings. . Render `py::int_` as `int` in docstrings. . Test py::iterable/py::iterator representation in docstrings. . Setuptools record of headers. . Docs typo. . Ignore another type of visual studio project file. . Render `py::none` as `None` in docstrings. . Add failing optional test. . Optional dereference type deduction. . Compile error on GCC4.8. . Add additiona
2.2.405 Feb 2019 12:09 minor bugfix: Use new Python 3.7 Thread Specific Storage (TSS) implementation if available. #1454, #1517. Fixes for newer MSVC versions and C++17 mode. #1347, #1462. Propagate return value policies to type-specific casters when casting STL containers. #1455. Allow ostream-redirection of more than 1024 characters. #1479. Set Py_DEBUG define when compiling against a debug Python build. #1438. Untangle integer logic in number type caster to work for custom types that may only be castable to a restricted set of builtin types. #1442. CMake build system: Remember Python version in cache file. #1434. Fix for custom smart pointers: use std::addressof to obtain holder address instead of operator . #1435. Properly report exceptions thrown during module initialization. #1362. Fixed a segmentation fault when creating empty-shaped NumPy array. #1371. The version of Intel C++ compiler must be = 2017, and this is now checked by the header files. #1363. A few minor typo fixes and improvements to the test suite, and patches that silence compiler warnings.