Seamless operability between C++11 and Python

pybind11 logo

pybind11 — Seamless operability between C++11 and Python

Latest Documentation Status Stable Documentation Status Gitter chat CI Build status

Repology PyPI package Conda-forge Python Versions

Setuptools exampleScikit-build exampleCMake example


Combining older versions of pybind11 (< 2.6.0) with Python 3.9.0 will trigger undefined behavior that typically manifests as crashes during interpreter shutdown (but could also destroy your data. You have been warned.)

We recommend that you update to the latest patch release of Python (3.9.1), which includes a fix that resolves this problem. If you do use Python 3.9.0, please update to the latest version of pybind11 (2.6.0 or newer), which includes a temporary workaround specifically when Python 3.9.0 is detected at runtime.

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.

The main issue with Boost.Python—and the reason for creating such a similar project—is Boost. Boost is an enormously large and complex suite of utility libraries that works with almost every C++ compiler in existence. This compatibility has its cost: arcane template tricks and workarounds are necessary to support the oldest and buggiest of compiler specimens. Now that C++11-compatible compilers are widely available, this heavy machinery has become an excessively large and unnecessary dependency.

Think of this library as a tiny self-contained version of Boost.Python with everything stripped away that isn’t relevant for binding generation. Without comments, the core header files only require ~4K lines of code and depend on Python (2.7 or 3.5+, or PyPy) and the C++ standard library. This compact implementation was possible thanks to some of the new C++11 language features (specifically: tuples, lambda functions and variadic templates). Since its creation, this library has grown beyond Boost.Python in many ways, leading to dramatically simpler binding code in many common situations.

Tutorial and reference documentation is provided at A PDF version of the manual is available here. And the source code is always available at

Core features

pybind11 can map the following core C++ features to Python:

  • Functions accepting and returning custom data structures per value, reference, or pointer
  • Instance methods and static methods
  • Overloaded functions
  • Instance attributes and static attributes
  • Arbitrary exception types
  • Enumerations
  • Callbacks
  • Iterators and ranges
  • Custom operators
  • Single and multiple inheritance
  • STL data structures
  • Smart pointers with reference counting like std::shared_ptr
  • Internal references with correct reference counting
  • C++ classes with virtual (and pure virtual) methods can be extended in Python


In addition to the core functionality, pybind11 provides some extra goodies:

  • Python 2.7, 3.5+, and PyPy/PyPy3 7.3 are supported with an implementation-agnostic interface.
  • It is possible to bind C++11 lambda functions with captured variables. The lambda capture data is stored inside the resulting Python function object.
  • pybind11 uses C++11 move constructors and move assignment operators whenever possible to efficiently transfer custom data types.
  • It’s easy to expose the internal storage of custom data types through Pythons’ buffer protocols. This is handy e.g. for fast conversion between C++ matrix classes like Eigen and NumPy without expensive copy operations.
  • pybind11 can automatically vectorize functions so that they are transparently applied to all entries of one or more NumPy array arguments.
  • Python’s slice-based access and assignment operations can be supported with just a few lines of code.
  • Everything is contained in just a few header files; there is no need to link against any additional libraries.
  • Binaries are generally smaller by a factor of at least 2 compared to equivalent bindings generated by Boost.Python. A recent pybind11 conversion of PyRosetta, an enormous Boost.Python binding project, reported a binary size reduction of 5.4x and compile time reduction by 5.8x.
  • Function signatures are precomputed at compile time (using constexpr), leading to smaller binaries.
  • With little extra effort, C++ types can be pickled and unpickled similar to regular Python objects.

Supported compilers

  1. Clang/LLVM 3.3 or newer (for Apple Xcode’s clang, this is 5.0.0 or newer)
  2. GCC 4.8 or newer
  3. Microsoft Visual Studio 2015 Update 3 or newer
  4. Intel classic C++ compiler 18 or newer (ICC 20.2 tested in CI)
  5. Cygwin/GCC (previously tested on 2.5.1)
  6. NVCC (CUDA 11.0 tested in CI)
  7. NVIDIA PGI (20.9 tested in CI)


This project was created by Wenzel Jakob. Significant features and/or improvements to the code were contributed by Jonas Adler, Lori A. Burns, Sylvain Corlay, Eric Cousineau, Ralf Grosse-Kunstleve, Trent Houliston, Axel Huebl, @hulucc, Yannick Jadoul, Sergey Lyskov Johan Mabille, Tomasz Miąsko, Dean Moldovan, Ben Pritchard, Jason Rhinelander, Boris Schäling, Pim Schellart, Henry Schreiner, Ivan Smirnov, Boris Staletic, and Patrick Stewart.

We thank Google for a generous financial contribution to the continuous integration infrastructure used by this project.


See the contributing guide for information on building and contributing to pybind11.


pybind11 is provided under a BSD-style license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.

  • error_already_set::what() is now constructed lazily

    error_already_set::what() is now constructed lazily

    The original motivation for this PR was a performance optimization. See the original PR description below.

    After nearly 3 years, work on this PR has led to a few related but distinct behavior changes:

    • Already merged PR #3971 — Fixes formatting of messages for originally unnormalized Python errors.
    • Already merged PR #3982

    This PR:

    • Secondary errors during normalization of the Python error are clearly reported (see test_flaky_exception_failure_point_init in
    • Secondary errors obtaining the error message are clearly reported (see test_flaky_exception_failure_point_str in
    • Calling error_already_set::restore() multiple times is clearly reported (preempts accidentally clearing an error, or accidentally restoring the same error twice; see test_error_already_set_double_restore in
    • The error_already_set copy constructor is no longer racy.
    • detail::error_string() no longer restores the error message. This fixes (in practice inconsequential) bugs in detail/class.h.

    The performance gain for exceptions with long tracebacks can be very substantial. See for concrete numbers.

    A review of the error_already_set development history is under

    Original PR description below

    Prior to this PR throwing error_already_set was expensive due to the eager construction of the error string. The PR changes error_already_set::what to construct the error string on first call.


    1.7 µs ± 9.03 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)


    1.14 µs ± 1.93 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)


    const py::int_ foo() {
        py::dict d;
        try {
            return d["foo"];
        } catch (const py::error_already_set &) {
            return py::int_(42);
    PYBIND11_MODULE(foo, m) {
      m.def("foo", &foo);

    Note that the running time of the benchmark is dominated by stack unwinding, therefore the speedup is only ~30%.

    Suggested changelog entry:

    ``error_already_set`` is now safer and more performant, especially for exceptions with long tracebacks.
    opened by superbobry 111
  • Support NVidia HPC SDK (PGI)

    Support NVidia HPC SDK (PGI)

    In this PR:

    • Support NVidia HPC SDK with PG compilers
    • Factor out CMake filter function
    • Allow CMake to build even if pytest is missing (still shows warning)

    Closes #2214 and closes #2407.

    opened by andriish 64
  • WIP: PyPy support

    WIP: PyPy support

    This commit includes a few minor modifications to pybind11 that are needed to get simple hello-world style functions to compile and run on the latest PyPy. Types are now supported as well.

    The test suite compiles but crashes when executed.

    opened by wjakob 57
  • Intel ICC C++17 compatibility

    Intel ICC C++17 compatibility

    Adds C++17 support.

    • ICC can’t handle complex enable if’s inline, like enable_if_t<all_of<is_positional<Args>...>::value>>, but if it is refactored into a separate constexpr function, it works.
      • But MSVC doesn't like it if the function is in the return type.
    • Fold expressions cause an internal compiler error, so we have to avoid turning them on even in C++17 mode
    • Plain noexcept can cause weird errors with following syntax, noexcept(true) works fine, workaround in tests

    This also fixes the NVIDIA HPC SDK compiler in C++17 mode.


    The Intel compiler has trouble with pybind11 when compiling in C++17 mode. The first two examples in the code below result in errors like "no instance of function template [...] matches the argument list", while the third one triggers an internal compiler error.

    #include <pybind11/pybind11.h>
    void test1() {
      pybind11::print("Hello World");
    void test2(pybind11::object obj) {
    class C {
    void test3(pybind11::module_ &m) {
    	pybind11::class_<C>(m, "C");

    Details can be found in #2707. @tobiasleibner implemented the fix for the template mismatch, while the workaround for the internal compiler error is mine. Part of @tobiasleibner's work went into #2573 already, which hasn't been merged yet. Since he currently doesn't have time, he suggested I post a pull request.

    Related to #2573 Fixes #2714 Fixes #2707

    Suggested changelog entry:

    * Support ICC and NVIDIA HPC SDK in C++17 mode
    compiler: intel 
    opened by mkuron 48
  • CMake installation path consistency

    CMake installation path consistency


    1. In a given installation PREFIX, pip install pybind11 or conda install pybind11 will install pybind11 headers into a new pybind11 subdirectory of the python include directory, while cmake + make install results in pybind11 headers being put into PREFIX/include/pybind11.

      For example, with a conda installation, pip will give

      PREFIX/include/pythonX.Y/pybind11 while cmake yields PREFIX/include/pybind11.

    2. It would be nice to have a consistent installation scheme between the two methods, plus the benefit of having the cmake project config files being made available, in the context of conda.


    This changes the destination of the headers of pybind into PYTHON_INCLUDE_DIRS/pybind11.

    The generated project config cmake files are installed in the same location as before, but reflect the new location of the headers.

    opened by SylvainCorlay 48
  • CI: Intel icc/icpc via oneAPI

    CI: Intel icc/icpc via oneAPI

    Add testing for Intel icc/icpc via the oneAPI images. Intel oneAPI is in a late beta stage, currently shipping oneAPI beta09 with ICC 20.2.

    We are adding // [workaround(intel)] near the workarounds to it will be easy to search them out later, and disable them to see if they have been fixed by the Intel compiler team.

    Here are the workarounds here:

    • py::args() -> py::args{}, in tests, regression in ICC 20+, workaround in tests
    • = default instead of {} doesn’t always work (was a recent modernization, so might have been a problem before too), workaround in tests

    Suggested changelog entry:

    * Support Intel OneAPI compiler (ICC 20.2) and add to CI.
    enhancement compiler: intel 
    opened by ax3l 46
  • WIP: Multiple inheritance support

    WIP: Multiple inheritance support

    This is an early snapshot of a potential way to support multiple inheritance in a minimally intrusive way. Standard single inheritance is supported using a fast fallback that matches the current implementation.

    Somewhat surprisingly, the change and related simplifications actually reduce the size of generated binaries by 4.4% :).

    There are probably a ton of cases that I didn't think of, so this is up for public review now.

    opened by wjakob 46
  • Fix cmake configuration when lto flags not available

    Fix cmake configuration when lto flags not available

    CMake current fails to run with Clang on linux:

    $ CC=clang CXX=clang++ cmake ..
    ... (various configuration) ...
    -- Configuring done
    CMake Error at tools/pybind11Tools.cmake:135 (target_compile_options):
      Error evaluating generator expression:
      Expression did not evaluate to a known generator expression
    Call Stack (most recent call first):
      tests/CMakeLists.txt:68 (pybind11_add_module)

    This commit fixes the generator expressions when the lto flags are not found (they will be empty strings, but the generator expression needs a 0).

    opened by jagerman 45
  • export interface lib through `pybind11Config.cmake`

    export interface lib through `pybind11Config.cmake`


    Acquiring the pybind11 repo (for large projects where the pybind11_add_module isn't appropriate) is admittedly not hard either as a git submodule or as a CMake ExternalProject plus writing a Findpybind11.cmake file to search out the header location. But for the ExternalProject case, the better CMake route is to provide a pybind11Config.cmake in the installation so that consuming projects can use pre-built (installed) pybind11 without writing their own detection.

    PR Changes

    • [x] Builds a minimal interface library target (pb11) and exports it so that pybind11Config.cmake and pybind11Targets.cmake are installed along with the headers. Instructions for detection and use given in tools/
    • [x] Allows passing -DCMAKE_INSTALL_INCLUDEDIR to specify non-standard install location. Defaults to include. Note that this isn't affecting the pybind11_add_module function since it's not exporting interface include dirs.


    • [x] Used pybind11::pybind11 for imported target name. If you want any other capitalization pattern for the project name, let me know and I'll adjust everything.
    • [x] I've hard-coded the version at 1.8, but the write_basic_package_version_file(...) four lines and the ConfigVersion.cmake installation can be commented out, if you don't want to deal with versioning in development mode.
    • I'm medium proficient at CMake, so please let me know if you see any holes in the procedure, would like some edits, or want the PR split.

    CMake Version

    • Checked that GNUInstallDirs and CMakePackageConfigHelpers present at 2.8.12 (
    • Checked that the $<INSTALL_INTERFACE generator present at 2.8.12 (
    • Couldn't find a 2.8.12 to install, but can confirm the exported target exports at 3.0.1
    opened by loriab 45
  • Add support for implicit conversions to C++ types

    Add support for implicit conversions to C++ types

    This PR adds a new py::implicitly_cpp_convertible<From,To>() tells pybind() that From can be implicitly converted to To (in C++), and thus pybind11-registered From types can be used in methods that accept (C++) To instances.

    (See issue #259)

    In essence, this lets you make use of C++ implicit converters (typically via a 'From::operator To()' or a non-explicit 'To::To(const From&)' constructor) with pybind11 instances without needing to create an explicit pybind11 interface for the conversion.

    As a simple example, consider the two classes:

        class A {
            void method(uint64_t val) { ... }
        class B {
            operator uint64_t() { ... } // returns unique identifier

    In C++, you can call a.method(22) or a.method(b). Telling pybind11 about the conversion allows you to do the same in python.

    Without the implicit conversion, you would have to either overload A.method to accept both uint64_t and B instances, or would have to add a method to B's interface that returns the id, then pass this method result to A's method.

    opened by jagerman 45
  • [smart_holder] Add a new return value policy `return_as_bytes`

    [smart_holder] Add a new return value policy `return_as_bytes`


    Add a new return value policy return_as_bytes to make C++ functions return bytes to Python instead of str.

    We can convert return values to bytes by applying py::bytes, but this might be hard when dealing with nested types.

    opened by wangxf123456 42
  • [BUG]: void value not ignored as it ought to be

    [BUG]: void value not ignored as it ought to be

    Required prerequisites

    Problem description

    the bind code like this :

    #include <pybind11/pybind11.h>
    #include <iostream>
    namespace py = pybind11;
    using std::cout;
    using std::endl;
    class Animal {
        virtual ~Animal() { }
        virtual void* go() = 0;
    class PyAnimal : public Animal {
        /* Inherit the constructors */
        using Animal::Animal;
        /* Trampoline (need one for each virtual function) */
        void* go() override {
                void*, /* Return type */
                Animal,      /* Parent class */
                go,          /* Name of function in C++ (must match Python name) */
    PYBIND11_MODULE(example, m) {
        py::class_<Animal, PyAnimal /* <--- trampoline*/>(m, "Animal")
            .def("go", &Animal::go);

    use pybind11 2.10.0,get error below:

    example.cpp: In member function ‘virtual void* PyAnimal::go(int)’:
    example.cpp:21:9: error: void value not ignored as it ought to be
       21 |         PYBIND11_OVERRIDE_PURE(
          |         ^~~~~~~~~~~~~~~~~~~~~~
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    but use pybind 2.9.2 is ok ,how to deal with it ??

    Reproducible example code

    No response

    opened by consolexinhun 0
  • Allow prealloc and registration before calling C++ ctor

    Allow prealloc and registration before calling C++ ctor


    This is a attempt to allow access to a Python derived class instance from C++ constructor. At this time, the constructor is called before allocation and registration so py::cast(this) inside constructor doesn't return the expected Python object.

    This PR:

    • adds a new preallocate annotation to be passed when declaring a constructor to select new specializations
      • this extra is added to keep the current behavior, e.g. not rely on placement new operator
    • adds specializations (relying on SFINAE) of constructor::execute and alias_constructor::execute to
      • allocate the memory
      • register the C++ object
      • call the constructor using a placement new operator


    • add tests
    • check is the preallocate could be removed after being used, instead of being passed to the def method


    opened by adriendelsalle 3
  • [BUG]: Python 3.12 support

    [BUG]: Python 3.12 support

    Required prerequisites

    Problem description

    @tacaswell reported that from Python 3.12 breaks pybind11, which in turn breaks matplotlib. We should probably both fix this and see if we can reenable the dev tag for 3.12 testing (Might also be good to start playing with using PyType_FromMetaclass too).

    Reproducible example code

    No response

    opened by henryiii 2
  • [QUESTION]: Example for wrapping std::variant

    [QUESTION]: Example for wrapping std::variant

    Required prerequisites

    Problem description


    I am evaluating pybind11 and I was able to wrap many things without trouble, until trying to wrap a function taking a std::variant as argument. In the documentation I understand that I do not need to use type_caster because it it seems to me that it is already defined in pybind11/stl.h for std::variant. However I think I am missing something, because I would expect to have to call some py::class_ function specifically for the variant (?).

    I found no example for wrapping a std::variant in the documentation or elsewhere on the internet or in pybind's test suite. Sorry if this is actually trivial.

    Here is an example code and associated compilation error I have with MSVC:

    pybind11\include\pybind11/pybind11.h(167): error C2280: 'pybind11::detail::argument_loader<pybind11::detail::value_and_holder &,MyVariant>::argument_loader(void)': attempting to reference a deleted function pybind11\include\pybind11\cast.h(1445): note: compiler has generated 'pybind11::detail::argument_loader<pybind11::detail::value_and_holder &,MyVariant>::argument_loader' here pybind11\include\pybind11\cast.h(1445): note: 'pybind11::detail::argument_loader<pybind11::detail::value_and_holder &,MyVariant>::argument_loader(void)': function was implicitly deleted because a data member 'pybind11::detail::argument_loader<pybind11::detail::value_and_holder &,MyVariant>::argcasters' has either no appropriate default constructor or overload resolution was ambiguous pybind11\include\pybind11\cast.h(1444): note: see declaration of 'pybind11::detail::argument_loader<pybind11::detail::value_and_holder &,MyVariant>::argcasters' ybind11\include\pybind11/pybind11.h(99): note: see reference to function template instantiation 'void pybind11::cpp_function::initialize<Ty,R,pybind11::detail::value_and_holder&,MyVariant,pybind11::name,pybind11::is_method,pybind11::sibling,pybind11::detail::is_new_style_constructor>(Func &&,Return (cdecl *)(pybind11::detail::value_and_holder &,MyVariant),const pybind11::name &,const pybind11::is_method &,const pybind11::sibling &,const pybind11::detail::is_new_style_constructor &)' being compiled with [ _Ty=pybind11::detail::initimpl::constructor::execute::<lambda_4bce0e84265d89e846bdadb006aa47c7>, R=void, Func=pybind11::detail::initimpl::constructor::execute::<lambda_4bce0e84265d89e846bdadb006aa47c7>, Return=void ] pybind11\include\pybind11/pybind11.h(1557): note: see reference to function template instantiation 'pybind11::cpp_function::cpp_function<Ty,pybind11::name,pybind11::is_method,pybind11::sibling,pybind11::detail::is_new_style_constructor,void>(Func &&,const pybind11::name &,const pybind11::is_method &,const pybind11::sibling &,const pybind11::detail::is_new_style_constructor &)' being compiled with [ _Ty=pybind11::detail::initimpl::constructor::execute::<lambda_4bce0e84265d89e846bdadb006aa47c7>, Func=pybind11::detail::initimpl::constructor::execute::<lambda_4bce0e84265d89e846bdadb006aa47c7> ] pybind11\include\pybind11\detail/init.h(199): note: see reference to function template instantiation 'pybind11::class &pybind11::class::def<pybind11::detail::initimpl::constructor::execute::<lambda_4bce0e84265d89e846bdadb006aa47c7>,pybind11::detail::is_new_style_constructor>(const char *,Func &&,const pybind11::detail::is_new_style_constructor &)' being compiled with [ Func=pybind11::detail::initimpl::constructor::execute::<lambda_4bce0e84265d89e846bdadb006aa47c7> ] pybind11\include\pybind11\detail/init.h(200): note: see reference to function template instantiation 'pybind11::class &pybind11::class::def<pybind11::detail::initimpl::constructor::execute::<lambda_4bce0e84265d89e846bdadb006aa47c7>,pybind11::detail::is_new_style_constructor>(const char *,Func &&,const pybind11::detail::is_new_style_constructor &)' being compiled with [ Func=pybind11::detail::initimpl::constructor::execute::<lambda_4bce0e84265d89e846bdadb006aa47c7> ] pybind11\include\pybind11/pybind11.h(1594): note: see reference to function template instantiation 'void pybind11::detail::initimpl::constructor::execute<pybind11::class_,,0>(Class &)' being compiled with [ Class=pybind11::class_ ] pybind11\include\pybind11/pybind11.h(1596): note: see reference to function template instantiation 'void pybind11::detail::initimpl::constructor::execute<pybind11::class_,,0>(Class &)' being compiled with [ Class=pybind11::class_ ] pybind_example.cpp(27): note: see reference to function template instantiation 'pybind11::class_ &pybind11::class_::def<MyVariant,>(const pybind11::detail::initimpl::constructor &)' being compiled pybind_example.cpp(28): note: see reference to function template instantiation 'pybind11::class_ &pybind11::class_::def<MyVariant,>(const pybind11::detail::initimpl::constructor &)' being compiled

    Reproducible example code

    #include <variant>
    #include <vector>
    class MyClassA
        MyClassA(double x) {}
    class MyClassB
        MyClassB(const std::vector<double>& x) {}
    using MyVariant = std::variant<MyClassA, MyClassB>;
    class MyTestClass
        MyTestClass(const MyVariant& variant) {}
    #include <pybind11/pybind11.h>
    #include <pybind11/stl.h>
    namespace py = pybind11;
    PYBIND11_MODULE(MyModule, m) {
        py::class_<MyClassA>(m, "MyClassA")
        py::class_<MyClassB>(m, "MyClassB")
        py::class_<MyTestClass>(m, "MyTestClass")
            .def(py::init<MyVariant>()); // compilation problem here

    Example code which does not reproduce

    #include <variant>
    class MyClassA
        MyClassA() {}
    class MyClassB
        MyClassB(double x) {}
    using MyVariant = std::variant<MyClassA, MyClassB>;
    class MyTestClass
        MyTestClass(const MyVariant& variant) {}
    #include <pybind11/pybind11.h>
    #include <pybind11/stl.h>
    namespace py = pybind11;
    PYBIND11_MODULE(MyModule, m) {
        py::class_<MyClassA>(m, "MyClassA")
        py::class_<MyClassB>(m, "MyClassB")
        py::class_<MyTestClass>(m, "MyTestClass")
            .def(py::init<MyVariant>()); // compilation problem here
    opened by gabrieldevillers 2
  • chore: Use PyObject_GenericGetDict and PyObject_GenericSetDict functions

    chore: Use PyObject_GenericGetDict and PyObject_GenericSetDict functions


    Remove custom implementation of PyObject_GenericGetDict and PyObject_GenericSetDict. These functions have been exposed since Python 3.3 and have both been part of the stable API since 3.10. Since we don't support Python 2 anymore, there is no reason to keep them around.

    Suggested changelog entry:

    * Use the modern PyObject_GenericGetDict and PyObject_GenericSetDict for handling dynamic attribute dictionaries.
    opened by Skylion007 0
  • v2.10.0(Jul 16, 2022)

    Removed support for Python 2.7, Python 3.5, and MSVC 2015. Support for MSVC 2017 is limited due to availability of CI runners; we highly recommend MSVC 2019 or 2022 be used. Initial support added for Python 3.11.

    New features:

    • py::anyset & py::frozenset were added, with copying (cast) to std::set (similar to set). #3901
    • Support bytearray casting to string. #3707
    • type_caster<std::monostate> was added. std::monostate is a tag type that allows std::variant to act as an optional, or allows default construction of a std::variant holding a non-default constructible type. #3818
    • pybind11::capsule::set_name added to mutate the name of the capsule instance. #3866
    • NumPy: dtype constructor from type number added, accessors corresponding to Python API dtype.num, dtype.byteorder, dtype.flags and dtype.alignment added. #3868


    • Python 3.6 is now the minimum supported version. #3688 #3719
    • The minimum version for MSVC is now 2017. #3722
    • Fix issues with CPython 3.11 betas and add to supported test matrix. #3923
    • error_already_set is now safer and more performant, especially for exceptions with long tracebacks, by delaying computation. #1895
    • Improve exception handling in python str bindings. #3826
    • The bindings for capsules now have more consistent exception handling. #3825
    • PYBIND11_OBJECT_CVT and PYBIND11_OBJECT_CVT_DEFAULT macro can now be used to define classes in namespaces other than pybind11. #3797
    • Error printing code now uses PYBIND11_DETAILED_ERROR_MESSAGES instead of requiring NDEBUG, allowing use with release builds if desired. #3913
    • Implicit conversion of the literal 0 to pybind11::handle is now disabled. #4008

    Bug fixes:

    • Fix exception handling when pybind11::weakref() fails. #3739
    • module_::def_submodule was missing proper error handling. This is fixed now. #3973
    • The behavior or error_already_set was made safer and the highly opaque "Unknown internal error occurred" message was replaced with a more helpful message. #3982
    • error_already_set::what() now handles non-normalized exceptions correctly. #3971
    • Support older C++ compilers where filesystem is not yet part of the standard library and is instead included in std::experimental::filesystem. #3840
    • Fix -Wfree-nonheap-object warnings produced by GCC by avoiding returning pointers to static objects with return_value_policy::take_ownership. #3946
    • Fix cast from pytype rvalue to another pytype. #3949
    • Ensure proper behavior when garbage collecting classes with dynamic attributes in Python >=3.9. #4051
    • A couple long-standing PYBIND11_NAMESPACE __attribute__((visibility("hidden"))) inconsistencies are now fixed (affects only unusual environments). #4043
    • pybind11::detail::get_internals() is now resilient to in-flight Python exceptions. #3981
    • Arrays with a dimension of size 0 are now properly converted to dynamic Eigen matrices (more common in NumPy 1.23). #4038
    • Avoid catching unrelated errors when importing NumPy. #3974

    Performance and style:

    • Added an accessor overload of (object &&key) to reference steal the object when using python types as keys. This prevents unnecessary reference count overhead for attr, dictionary, tuple, and sequence look ups. Added additional regression tests. Fixed a performance bug the caused accessor assignments to potentially perform unnecessary copies. #3970
    • Perfect forward all args of make_iterator. #3980
    • Avoid potential bug in pycapsule destructor by adding an error_guard to one of the dtors. #3958
    • Optimize dictionary access in strip_padding for numpy. #3994
    • stl_bind.h bindings now take slice args as a const-ref. #3852
    • Made slice constructor more consistent, and improve performance of some casters by allowing reference stealing. #3845
    • Change numpy dtype from_args method to use const ref. #3878
    • Follow rule of three to ensure PyErr_Restore is called only once. #3872
    • Added missing perfect forwarding for make_iterator functions. #3860
    • Optimize c++ to python function casting by using the rvalue caster. #3966
    • Optimize Eigen sparse matrix casting by removing unnecessary temporary. #4064
    • Avoid potential implicit copy/assignment constructors causing double free in strdup_gaurd. #3905
    • Enable clang-tidy checks misc-definitions-in-headers, modernize-loop-convert, and modernize-use-nullptr. #3881 #3988

    Build system improvements:

    • CMake: Fix file extension on Windows with cp36 and cp37 using FindPython. #3919
    • CMake: Support multiple Python targets (such as on vcpkg). #3948
    • CMake: Fix issue with NVCC on Windows. #3947
    • CMake: Drop the bitness check on cross compiles (like targeting WebAssembly via Emscripten). #3959
    • Add MSVC builds in debug mode to CI. #3784
    • MSVC 2022 C++20 coverage was added to GitHub Actions, including Eigen. #3732, #3741

    Backend and tidying up:

    • New theme for the documentation. #3109
    • Remove idioms in code comments. Use more inclusive language. #3809
    • #include <iostream> was removed from the pybind11/stl.h header. Your project may break if it has a transitive dependency on this include. The fix is to "Include What You Use". #3928
    • Avoid <command> usage in internal tests. #3734
    Source code(tar.gz)
    Source code(zip)
  • v2.9.2(Mar 31, 2022)


    • Enum now has an __index__ method on Python <3.8 too. #3700
    • Local internals are now cleared after finalizing the interpreter. #3744

    Bug fixes:

    • Better support for Python 3.11 alphas. #3694
    • PYBIND11_TYPE_CASTER now uses fully qualified symbols, so it can be used outside of pybind11::detail. #3758
    • Some fixes for PyPy 3.9. #3768
    • Fixed a potential memleak in PyPy in get_type_override. #3774
    • Fix usage of VISIBILITY_INLINES_HIDDEN. #3721

    Build system improvements:

    • Uses sysconfig module to determine installation locations on Python >= 3.10, instead of distutils which has been deprecated. #3764
    • Support Catch 2.13.5+ (supporting GLIBC 2.34+). #3679
    • Fix test failures with numpy 1.22 by ignoring whitespace when comparing str() of dtypes. #3682

    Backend and tidying up:

    • clang-tidy: added readability-qualified-auto, readability-braces-around-statements, cppcoreguidelines-prefer-member-initializer, clang-analyzer-optin.performance.Padding, cppcoreguidelines-pro-type-static-cast-downcast, and readability-inconsistent-declaration-parameter-name. #3702, #3699, #3716, #3709
    • clang-format was added to the pre-commit actions, and the entire code base automatically reformatted (after several iterations preparing for this leap). #3713
    Source code(tar.gz)
    Source code(zip)
  • v2.9.1(Feb 3, 2022)


    • If possible, attach Python exception with py::raise_from to TypeError when casting from C++ to Python. This will give additional info if Python exceptions occur in the caster. Adds a test case of trying to convert a set from C++ to Python when the hash function is not defined in Python. #3605
    • Add a mapping of C++11 nested exceptions to their Python exception equivalent using py::raise_from. This attaches the nested exceptions in Python using the __cause__ field. #3608
    • Propagate Python exception traceback using raise_from if a pybind11 function runs out of overloads. #3671
    • py::multiple_inheritance is now only needed when C++ bases are hidden from pybind11. #3650 and #3659

    Bug fixes:

    • Remove a boolean cast in numpy.h that causes MSVC C4800 warnings when compiling against Python 3.10 or newer. #3669
    • Render py::bool_ and py::float_ as bool and float respectively. #3622

    Build system improvements:

    • Fix CMake extension suffix computation on Python 3.10+. #3663
    • Allow CMAKE_ARGS to override CMake args in pybind11's own #3577
    • Remove a few deprecated c-headers. #3610
    • More uniform handling of test targets. #3590
    • Add clang-tidy readability check to catch potentially swapped function args. #3611
    Source code(tar.gz)
    Source code(zip)
  • v2.9.0(Dec 28, 2021)

    This is the last version to support Python 2.7 and 3.5.

    New Features:

    • Allow py::args to be followed by other arguments; the remaining arguments are implicitly keyword-only, as if a py::kw_only{} annotation had been used. #3402


    • Make str/bytes/memoryview more interoperable with std::string_view. #3521
    • Replace _ with const_name in internals, avoid defining pybind::_ if _ defined as macro (common gettext usage) #3423

    Bug fixes:

    • Fix a rare warning about extra copy in an Eigen constructor. #3486
    • Fix caching of the C++ overrides. #3465
    • Add missing std::forward calls to some cpp_function overloads. #3443
    • Support PyPy 7.3.7 and the PyPy3.8 beta. Test python-3.11 on PRs with the python dev label. #3419
    • Replace usage of deprecated Eigen::MappedSparseMatrix with Eigen::Map<Eigen::SparseMatrix<...>> for Eigen 3.3+. #3499
    • Tweaks to support Microsoft Visual Studio 2022. #3497

    Build system improvements:

    • Nicer CMake printout and IDE organisation for pybind11's own tests. #3479
    • CMake: report version type as part of the version string to avoid a spurious space in the package status message. #3472
    • Flags starting with -g in $CFLAGS and $CPPFLAGS are no longer overridden by .Pybind11Extension. #3436
    • Ensure ThreadPool is closed in setup_helpers. #3548
    • Avoid LTS on mips64 and ppc64le (reported broken). #3557
    Source code(tar.gz)
    Source code(zip)
  • v2.8.1(Oct 27, 2021)

    v2.8.1 (Oct 27, 2021)

    Changes and additions:

    • The simple namespace creation shortcut added in 2.8.0 was deprecated due to usage of CPython internal API, and will be removed soon. Use py::module_::import("types").attr("SimpleNamespace"). #3374
    • Add C++ Exception type to throw and catch AttributeError. Useful for defining custom __setattr__ and __getattr__ methods. #3387


    • Fixed the potential for dangling references when using properties with std::optional types. #3376
    • Modernize usage of PyCodeObject on Python 3.9+ (moving toward support for Python 3.11a1) #3368
    • A long-standing bug in eigen.h was fixed (originally PR #3343). The bug was unmasked by newly added static_assert's in the Eigen 3.4.0 release. #3352
    • Support multiple raw inclusion of CMake helper files ( does this for multi-config generators). #3420
    • Fix harmless warning on upcoming CMake 3.22. #3368
    • Fix 2.8.0 regression with MSVC 2017 + C++17 mode + Python 3. #3407
    • Fix 2.8.0 regression that caused undefined behavior (typically segfaults) in make_key_iterator/make_value_iterator if dereferencing the iterator returned a temporary value instead of a reference. #3348
    Source code(tar.gz)
    Source code(zip)
  • v2.8.0(Oct 4, 2021)

    New features:

    • Added py::raise_from to enable chaining exceptions. #3215
    • Allow exception translators to be optionally registered local to a module instead of applying globally across all pybind11 modules. Use register_local_exception_translator(ExceptionTranslator&& translator) instead of register_exception_translator(ExceptionTranslator&& translator) to keep your exception remapping code local to the module. #2650
    • Add make_simple_namespace function for instantiating Python SimpleNamespace objects. #2840
    • pybind11::scoped_interpreter and initialize_interpreter have new arguments to allow sys.argv initialization. #2341
    • Allow Python builtins to be used as callbacks in CPython. #1413
    • Added view to view arrays with a different datatype. #987
    • Implemented reshape on arrays. #984
    • Enable defining custom __new__ methods on classes by fixing bug preventing overriding methods if they have non-pybind11 siblings. #3265
    • Add make_value_iterator(), and fix make_key_iterator() to return references instead of copies. #3293
    • Improve the classes generated by bind_map: #3310
      • Change .items from an iterator to a dictionary view.
      • Add .keys and .values (both dictionary views).
      • Allow __contains__ to take any object.
    • pybind11::custom_type_setup was added, for customizing the PyHeapTypeObject corresponding to a class, which may be useful for enabling garbage collection support, among other things. #3287


    • Set __file__ constant when running eval_file in an embedded interpreter. #3233
    • Python objects and (C++17) std::optional now accepted in py::slice constructor. #1101
    • The pybind11 proxy types str, bytes, bytearray, tuple, list now consistently support passing ssize_t values for sizes and indexes. Previously, only size_t was accepted in several interfaces. #3219
    • Avoid evaluating PYBIND11_TLS_REPLACE_VALUE arguments more than once. #3290


    • Bug fix: enum value's __int__ returning non-int when underlying type is bool or of char type #1334
    • Fixes bug in setting error state in Capsule's pointer methods. #3261
    • A long-standing memory leak in py::cpp_function::initialize was fixed. #3229
    • Fixes thread safety for some pybind11::type_caster which require lifetime extension, such as for std::string_view. #3237
    • Restore compatibility with gcc 4.8.4 as distributed by ubuntu-trusty, linuxmint-17. #3270

    Build system improvements:

    • Fix regression in CMake Python package config: improper use of absolute path. #3144
    • Cached Python version information could become stale when CMake was re-run with a different Python version. The build system now detects this and updates this information. #3299
    • Specified UTF8-encoding in calls of open(). #3137
    • Fix a harmless warning from CMake 3.21 with the classic Python discovery. #3220
    • Eigen repo and version can now be specified as cmake options. #3324

    Backend and tidying up:

    • Reduced thread-local storage required for keeping alive temporary data for type conversion to one key per ABI version, rather than one key per extension module. This makes the total thread-local storage required by pybind11 2 keys per ABI version. #3275
    • Optimize NumPy array construction with additional moves. #3183
    • Conversion to std::string and std::string_view now avoids making an extra copy of the data on Python >= 3.3. #3257
    • Remove const modifier from certain C++ methods on Python collections (list, set, dict) such as (clear(), append(), insert(), etc...) and annotated them with py-non-const.
    • Enable readability clang-tidy-const-return and remove useless consts. #3254 #3194
    • The clang-tidy google-explicit-constructor option was enabled. #3250
    • Mark a pytype move constructor as noexcept (perf). #3236
    • Enable clang-tidy check to guard against inheritance slicing. #3210
    • Legacy warning suppression pragma were removed from eigen.h. On Unix platforms, please use -isystem for Eigen include directories, to suppress compiler warnings originating from Eigen headers. Note that CMake does this by default. No adjustments are needed for Windows. #3198
    • Format pybind11 with isort consistent ordering of imports #3195
    • The warnings-suppression "pragma clamp" at the top/bottom of pybind11 was removed, clearing the path to refactoring and IWYU cleanup. #3186
    • Enable most bugprone checks in clang-tidy and fix the found potential bugs and poor coding styles. #3166
    • Add clang-tidy-readability rules to make boolean casts explicit improving code readability. Also enabled other misc and readability clang-tidy checks. #3148
    • Move object in .pop() for list. #3116
    Source code(tar.gz)
    Source code(zip)
  • v2.7.1(Aug 3, 2021)

    Minor missing functionality added:

    • Allow Python builtins to be used as callbacks in CPython. #1413

    Bug fixes:

    • Fix regression in CMake Python package config: improper use of absolute path. #3144
    • Fix Mingw64 and add to the CI testing matrix. #3132
    • Specified UTF8-encoding in calls of open(). #3137
    • Add clang-tidy-readability rules to make boolean casts explicit improving code readability. Also enabled other misc and readability clang-tidy checks. #3148
    • Move object in .pop() for list. #3116

    Backend and tidying up:

    Source code(tar.gz)
    Source code(zip)
  • v2.7.0(Jul 16, 2021)

    New features:

    • Enable py::implicitly_convertible<py::none, ...> for py::class_-wrapped types. #3059
    • Allow function pointer extraction from overloaded functions. #2944
    • NumPy: added .char_() to type which gives the NumPy public char result, which also distinguishes types by bit length (unlike .kind()). #2864
    • Add pybind11::bytearray to manipulate bytearray similar to bytes. #2799
    • pybind11/stl/filesystem.h registers a type caster that, on C++17/Python 3.6+, converts std::filesystem::path to pathlib.Path and any os.PathLike to std::filesystem::path. #2730
    • A PYBIND11_VERSION_HEX define was added, similar to PY_VERSION_HEX. #3120


    • py::str changed to exclusively hold PyUnicodeObject. Previously py::str could also hold bytes, which is probably surprising, was never documented, and can mask bugs (e.g. accidental use of py::str instead of py::bytes). #2409
    • Add a safety guard to ensure that the Python GIL is held when C++ calls back into Python via object_api<>::operator() (e.g. py::function __call__). (This feature is available for Python 3.6+ only.) #2919
    • Catch a missing self argument in calls to __init__(). #2914
    • Use std::string_view if available to avoid a copy when passing an object to a std::ostream. #3042
    • An important warning about thread safety was added to the iostream.h documentation; attempts to make py::scoped_ostream_redirect thread safe have been removed, as it was only partially effective. #2995


    • Performance: avoid unnecessary strlen calls. #3058
    • Fix auto-generated documentation string when using const T in pyarray_t. #3020
    • Unify error messages thrown by simple_collector/unpacking_collector. #3013
    • pybind11::builtin_exception is now explicitly exported, which means the types included/defined in different modules are identical, and exceptions raised in different modules can be caught correctly. The documentation was updated to explain that custom exceptions that are used across module boundaries need to be explicitly exported as well. #2999
    • Fixed exception when printing UTF-8 to a scoped_ostream_redirect. #2982
    • Pickle support enhancement: setstate implementation will attempt to setattr __dict__ only if the unpickled dict object is not empty, to not force use of py::dynamic_attr() unnecessarily. #2972
    • Allow negative timedelta values to roundtrip. #2870
    • Fix unchecked errors could potentially swallow signals/other exceptions. #2863
    • Add null pointer check with std::localtime. #2846
    • Fix the weakref constructor from py::object to create a new weakref on conversion. #2832
    • Avoid relying on exceptions in C++17 when getting a shared_ptr holder from a shared_from_this class. #2819
    • Allow the codec's exception to be raised instead of RuntimeError when casting from py::str to std::string. #2903

    Build system improvements:

    • In, test for platforms that have some multiprocessing features but lack semaphores, which ParallelCompile requires. #3043
    • Fix pybind11_INCLUDE_DIR in case CMAKE_INSTALL_INCLUDEDIR is absolute. #3005
    • Fix bug not respecting WITH_SOABI or WITHOUT_SOABI to CMake. #2938
    • Fix the default Pybind11Extension compilation flags with a Mingw64 python. #2921
    • Clang on Windows: do not pass /MP (ignored flag). #2824
    • pybind11.setup_helpers.intree_extensions can be used to generate Pybind11Extension instances from cpp files placed in the Python package source tree. #2831

    Backend and tidying up:

    • Enable clang-tidy performance, readability, and modernization checks throughout the codebase to enforce best coding practices. #3046, #3049, #3051, #3052, #3080, and #3094
    • Checks for common misspellings were added to the pre-commit hooks. #3076
    • Changed Werror to stricter Werror-all for Intel compiler and fixed minor issues. #2948
    • Fixed compilation with GCC < 5 when the user defines _GLIBCXX_USE_CXX11_ABI. #2956
    • Added nox support for easier local testing and linting of contributions. #3101 and #3121
    • Avoid RTD style issue with docutils 0.17+. #3119
    • Support pipx run, such as pipx run pybind11 --include for a quick compile. #3117
    Source code(tar.gz)
    Source code(zip)
  • v2.6.2(Jan 27, 2021)

    Minor missing functionality added:

    • enum: add missing Enum.value property. #2739
    • Allow thread termination to be avoided during shutdown for CPython 3.7+ via .disarm for gil_scoped_acquire/gil_scoped_release. #2657

    Fixed or improved behavior in a few special cases:

    • Fix bug where the constructor of object subclasses would not throw on being passed a Python object of the wrong type. #2701
    • The type_caster for integers does not convert Python objects with __int__ anymore with noconvert or during the first round of trying overloads. #2698
    • When casting to a C++ integer, __index__ is always called and not considered as conversion, consistent with Python 3.8+. #2801

    Build improvements:

    • Setup helpers: extra_compile_args and extra_link_args automatically set by Pybind11Extension are now prepended, which allows them to be overridden by user-set extra_compile_args and extra_link_args. #2808
    • Setup helpers: Don't trigger unused parameter warning. #2735
    • CMake: Support running with --warn-uninitialized active. #2806
    • CMake: Avoid error if included from two submodule directories. #2804
    • CMake: Fix STATIC / SHARED being ignored in FindPython mode. #2796
    • CMake: Respect the setting for CMAKE_CXX_VISIBILITY_PRESET if defined. #2793
    • CMake: Fix issue with FindPython2/FindPython3 not working with pybind11::embed. #2662
    • CMake: mixing local and installed pybind11's would prioritize the installed one over the local one (regression in 2.6.0). #2716

    Bug fixes:

    • Fixed segfault in multithreaded environments when using scoped_ostream_redirect. #2675
    • Leave docstring unset when all docstring-related options are disabled, rather than set an empty string. #2745
    • The module key in builtins that pybind11 uses to store its internals changed from std::string to a python str type (more natural on Python 2, no change on Python 3). #2814
    • Fixed assertion error related to unhandled (later overwritten) exception in CPython 3.8 and 3.9 debug builds. #2685
    • Fix py::gil_scoped_acquire assert with CPython 3.9 debug build. #2683
    • Fix issue with a test failing on PyTest 6.2. #2741

    Warning fixes:

    • Fix warning modifying constructor parameter 'flag' that shadows a field of 'set_flag' [-Wshadow-field-in-constructor-modified]. #2780
    • Suppressed some deprecation warnings about old-style __init__/__setstate__ in the tests. #2759

    Valgrind work:

    • Fix invalid access when calling a pybind11 __init__ on a non-pybind11 class instance. #2755
    • Fixed various minor memory leaks in pybind11's test suite. #2758
    • Resolved memory leak in cpp_function initialization when exceptions occurred. #2756
    • Added a Valgrind build, checking for leaks and memory-related UB, to CI. #2746

    Compiler support:

    • Intel compiler was not activating C++14 support due to a broken define. #2679
    • Support ICC and NVIDIA HPC SDK in C++17 mode. #2729
    • Support Intel OneAPI compiler (ICC 20.2) and add to CI. #2573
    Source code(tar.gz)
    Source code(zip)
  • v2.6.1(Nov 12, 2020)

    • 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 higher 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
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0(Oct 21, 2020)

    New features:

    • 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<T>() 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_<union_type> 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

    Code correctness features:

    • 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

    API changes:

    • py::module was renamed py::module_ to avoid issues 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, fixing inconsistencies in the presence of a closing ; in these macros. get_type_overload is deprecated. #2325

    Packaging / building improvements:

    • 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 can be used via PEP 518, setup_requires, or by directly importing or copying into your project.
      • CMake configuration files are now included in the Python package. Use pybind11.get_cmake_dir() or python -m pybind11 --cmakedir to get the directory with the CMake configuration files, or include the site-packages location in your CMAKE_MODULE_PATH. Or you can use the new pybind11[global] extra when you install pybind11, which installs the CMake files and headers into your base environment in the standard location.
      • pybind11-config is another way to write python -m pybind11 if you have your PATH set up.
      • Added external typing support to the helper module, code from import pybind11 can now be type checked. #2588
    • Minimum CMake required increased to 3.4. #2338 and #2370
      • Full integration with CMake's C++ standard system and compile features replaces PYBIND11_CPP_STANDARD.
      • Generated config file is now portable to different Python/compiler/CMake versions.
      • Virtual environments prioritized if PYTHON_EXECUTABLE is not set (venv, virtualenv, and conda) (similar to the new FindPython mode).
      • Other CMake features now natively supported, like CMAKE_INTERPROCEDURAL_OPTIMIZATION, set(CMAKE_CXX_VISIBILITY_PRESET hidden).
      • CUDA as a language is now supported.
      • Helper functions pybind11_strip, pybind11_extension, pybind11_find_import added, see cmake/index.
      • Optional find-python-mode and nopython-mode with CMake. #2370
    • Uninstall target added. #2265 and #2346
    • pybind11_add_module() now accepts an optional OPT_SIZE flag that switches the binding target to size-based optimization if the global build type can not always be fixed to MinSizeRel (except in debug mode, where optimizations remain disabled). MinSizeRel or this flag reduces binary size quite substantially (~25% on some platforms). #2463

    Smaller or developer focused features and fixes:

    • Moved to a new repo, pybind11-mkdoc. There are no longer submodules in the main repo.
    • py::memoryview segfault fix and update, with new py::memoryview::from_memory in Python 3, and documentation. #2223
    • Fix for buffer_info on Python 2. #2503
    • If __eq__ defined but not __hash__, __hash__ is now set to None. #2291
    • py::ellipsis now also works on Python 2. #2360
    • Pointer to std::tuple & std::pair supported in cast. #2334
    • Small fixes in NumPy support. py::array now uses py::ssize_t as first argument type. #2293
    • Added missing signature for py::array. #2363
    • unchecked_mutable_reference has access to operator () and [] when const. #2514
    • py::vectorize is now supported on functions that return void. #1969
    • py::capsule supports get_pointer and set_pointer. #1131
    • Fix crash when different instances share the same pointer of the same type. #2252
    • Fix for py::len not clearing Python's error state when it fails and throws. #2575
    • Bugfixes related to more extensive testing, new GitHub Actions CI. #2321
    • Bug in timezone issue in Eastern hemisphere midnight fixed. #2438
    • std::chrono::time_point now works when the resolution is not the same as the system. #2481
    • Bug fixed where py::array_t could accept arrays that did not match the requested ordering. #2484
    • Avoid a segfault on some compilers when types are removed in Python. #2564
    • py::arg::none() is now also respected when passing keyword arguments. #2611
    • PyPy fixes, PyPy 7.3.x now supported, including PyPy3. (Known issue with PyPy2 and Windows #2596). #2146
    • CPython 3.9.0 workaround for undefined behavior (macOS segfault). #2576
    • CPython 3.9 warning fixes. #2253
    • Improved C++20 support, now tested in CI. #2489 #2599
    • Improved but still incomplete debug Python interpreter support. #2025
    • NVCC (CUDA 11) now supported and tested in CI. #2461
    • NVIDIA PGI compilers now supported and tested in CI. #2475
    • At least Intel 18 now explicitly required when compiling with Intel. #2577
    • Extensive style checking in CI, with pre-commit support. Code modernization, checked by clang-tidy.
    • Expanded docs, including new main page, new installing section, and CMake helpers page, along with over a dozen new sections on existing pages.
    • In GitHub, new docs for contributing and new issue templates.
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0rc3(Oct 16, 2020)

    Next release candidate.

    • Factory constructor scope fix
    • Support for PyPy3 on Windows 32, added to CI
    • Fixes for C++20, added to CI for Clang, GCC, and MSVC 2019
    • Black formatting for all Python code
    • Allow ABI string overrides from 2.4 (advanced)
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0rc2(Oct 14, 2020)

    Next release candidate. Changes since RC 1:


    • Python 3.9.0 bug workaround implemented
    • Better support in CMake for packing and cross-compiling
    • Fix for failing py::len leaving error state set
    • Intel 18+ explicitly required, an issue with Intel compilers fixed
    • Custom ipo flags disabled with RelWithDebInfo (use CMAKE_INTERPROCEDURAL_OPTIMIZATION for more control)
    • Possible duplicate linker flags fixed in setup_helpers
    • Changes to py::module_ constructor are no longer provisional.

    New features:

    • Static typing support for import pybind11
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0rc1(Oct 9, 2020)

    This is the first release candidate for pybind11 2.6.0. Please see the new features in the changelog, such as revamped CMake and setuptools support, keyword and positional argument support, and a long list of features, fixes, and improvements. Full Python 3.9 support and enhanced C++20 support.

    Known issues:

    • py::module_ direct construction provisionally deprecated
    • Removing registered types can cause a segfault - old issue exposed by recent test additions; fix incoming
    • On Python 3.9.0 and macOS, pybind11 may segfault when closing the interpreter after running the test suite
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0b1(Sep 30, 2020)

Seamless operability between C++ and Python
Structy is an irresponsibly dumb and simple struct serialization/deserialization library for C, Python, and vanilla JavaScript.

Structy Structy is an irresponsibly dumb and simple struct serialization/deserialization library for C, Python, and vanilla JavaScript. You can think

Stargirl Flowers 47 Jun 19, 2022
Import C++ files directly from Python!

If you've used cppimport version 0.0.*, some new features for you! Compiler arguments, multiple source files, bug fixes! Read on. Import C or C++ file

Ben Thompson 1k Aug 8, 2022
The most widely used Python to C compiler

Welcome to Cython! Cython is a language that makes writing C extensions for Python as easy as Python itself. Cython is based on Pyrex, but supports mo

null 7.2k Aug 2, 2022
Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:

sol2 sol2 is a C++ library binding to Lua. It currently supports all Lua versions 5.1+ (LuaJIT 2.0+ and MoonJIT included). sol2 aims to be easy to use

The Phantom Derpstorm 3.1k Aug 1, 2022
Libraries and examples to support Pimoroni Pico add-ons in C++ and MicroPython.

Pimoroni Pico Libraries and Examples Welcome to the brave new world of Pico! This repository contains the C/C++ and MicroPython libraries for our rang

Pimoroni Ltd 565 Aug 11, 2022
Tools and libraries to glue C/C++ APIs to high-level languages

CppSharp is a tool and set of libraries which facilitates the usage of native C/C++ code with the .NET ecosystem. It consumes C/C++ header and library

Mono Project 2.4k Aug 7, 2022
A tool for generating cross-language type declarations and interface bindings.

Djinni Djinni is a tool for generating cross-language type declarations and interface bindings. It's designed to connect C++ with either Java or Objec

Dropbox 2.8k Aug 1, 2022
Duktape - embeddable Javascript engine with a focus on portability and compact footprint

Duktape ⚠️ Master branch is undergoing incompatible changes for Duktape 3.x. To track Duktape 2.x, follow the v2-maintenance branch. Introduction Dukt

Sami Vaarala 5.3k Aug 4, 2022
SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.

SWIG (Simplified Wrapper and Interface Generator) Version: 4.1.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages

SWIG 4.6k Aug 8, 2022
A minimalist and mundane scripting language.

Drift Script A minimalist and mundane scripting language. I like all simple things, simple and beautiful, simple and strong. I know that all developme

Drift 11 Apr 3, 2022
Python Inference Script is a Python package that enables developers to author machine learning workflows in Python and deploy without Python.

Python Inference Script(PyIS) Python Inference Script is a Python package that enables developers to author machine learning workflows in Python and d

Microsoft 10 Feb 23, 2022
DotX64Dbg aims to provide a seamless way to write and test plugins for X64Dbg using .Net 5.0 and C#.

DotX64Dbg (EARLY ALPHA) Plugins and Scripting with C# for x64Dbg. Create Plugins for X64Dbg with ease DotX64Dbg aims to provide a seamless way to writ

ζeh Matt 7 Jan 21, 2022
A seamless, gasketmounted QAZ-like 40% keyboard

QEZ A seamless, gasketmounted QAZ-like 40% keyboard STEP files for the case KiCAD PCB files Gerbers for PCB production JLCPCB BOM JLCPCB CPL Vial-QMK

null 56 Aug 1, 2022
Inter-process communication library to enable allocation between processes/threads and send/receive of allocated regions between producers/consumer processes or threads using this ipc buffer.

This is a relatively simple IPC buffer that allows multiple processes and threads to share a dynamic heap allocator, designate "channels" between processes, and share that memory between producer/consumer pairs on those channels.

RaftLib 7 May 24, 2022
A Binary Clock. Written 3 different ways. C and SDL, Python and PyGame, Python and PyGame Zero.

Super Clock A Binary Clock. Written 3 different ways. Python with PyGame Zero, Python with PyGame and C with SDL2. Time is displayed in 3 groups of 8

null 3 Dec 8, 2021
BLLIP reranking parser (also known as Charniak-Johnson parser, Charniak parser, Brown reranking parser) See for Python module.

BLLIP Reranking Parser Copyright Mark Johnson, Eugene Charniak, 24th November 2005 --- August 2006 We request acknowledgement in any publications that

Brown Laboratory for Linguistic Information Processing 212 Jul 19, 2022
A run-time C++ library for working with units of measurement and conversions between them and with string representations of units and measurements

Units What's new Some of the CMake target names have changed in the latest release, please update builds appropriately Documentation A library that pr

Lawrence Livermore National Laboratory 107 Aug 3, 2022
Cross-platform, efficient, customizable, and robust asynchronous HTTP/WebSocket server C++14 library with the right balance between performance and ease of use

What Is RESTinio? RESTinio is a header-only C++14 library that gives you an embedded HTTP/Websocket server. It is based on standalone version of ASIO

Stiffstream 871 Aug 9, 2022
Warp speed Data Transfer (WDT) is an embeddedable library (and command line tool) aiming to transfer data between 2 systems as fast as possible over multiple TCP paths.

WDT Warp speed Data Transfer Design philosophy/Overview Goal: Lowest possible total transfer time - to be only hardware limited (disc or network bandw

Facebook 2.7k Jul 26, 2022
The missing bridge between Java and native C++

JavaCPP Commercial support: Introduction JavaCPP provides efficient access to native C++ inside Java, not unlike the way some C/C++ compilers interact

Bytedeco 3.9k Aug 11, 2022
SetSketch: Filling the Gap between MinHash and HyperLogLog

SetSketch: Filling the Gap between MinHash and HyperLogLog This repository contains the source code to reproduce all the results and figures presented

Dynatrace Research 29 Jul 28, 2022
This repository is used for automatic calibration between high resolution LiDAR and camera in targetless scenes.

livox_camera_calib livox_camera_calib is a robust, high accuracy extrinsic calibration tool between high resolution LiDAR (e.g. Livox) and camera in t

HKU-Mars-Lab 399 Aug 11, 2022
Easy automated syncing between your computers and your MEGA Cloud Drive

Easy automated syncing between your computers and your MEGA Cloud Drive

Mega Limited 1.2k Aug 11, 2022
Transacted Hollowing - a PE injection technique, hybrid between ProcessHollowing and ProcessDoppelgänging

Transacted Hollowing Transacted Hollowing - a PE injection technique. A hybrid between Process Hollowing and Process Doppelgänging. More info here Cha

hasherezade 392 Aug 7, 2022
WeNet is to close the gap between research and production end-to-end (E2E) speech recognition models,

WeNet is to close the gap between research and production end-to-end (E2E) speech recognition models, to reduce the effort of productionizing E2E models, and to explore better E2E models for production.

null 2.3k Aug 9, 2022
sc-ble-bridge is a utility that for every connected Steam Controller creates a virtual one acting as a bridge between SC and Steam

sc-ble-bridge The main goal of this utility is to provide workaround for steam-for-linux issue which makes Valve's Steam Controller unusable in BLE mo

null 5 Apr 19, 2022
rlua -- High level bindings between Rust and Lua

rlua -- High level bindings between Rust and Lua

Amethyst Foundation 1.3k Aug 3, 2022
Pure C Arcade game. Cross between pong and breakout, made it by accident

LameBall I accidentally made this game while testing some code. It's kind of a cross between Pong and Breakout, mixed with Squash/Racquetball. >> DOWN

Phil Bagshaw 2 Sep 17, 2021
Another try to re-create Project Astoria , or some bridge between A and W...

Bridge Forked from: Abstract Another "Project Astoria" remake (UWP) Original status: Forgotten (?) My ac

Media Explorer 4 Jun 12, 2022