Skip to content

Releases: pybind/pybind11

Version 3.0.0 RC 1

21 May 20:14
fc888f7
Compare
Choose a tag to compare
Version 3.0.0 RC 1 Pre-release
Pre-release

What's Changed

Since this is a large release, we are providing a release candidate to give projects time to test! We also now provide SPEC 4 nightly wheels. We are hoping to split up std.h; that work is approved to be added during the RC phase if it's ready in time. We expect the RC phase to last around a week.

Pybind11 3.0 includes an ABI bump, the first required bump in many years on Unix (Windows has had required bumps more often). This release contains the smart-holder branch, multi-phase init and subinterpreter support, py::native_enum, an interface to warnings, typing improvements, and more. CMake now defaults to FindPython mode. Please check our upgrade guide for more info on upgrading!

Support for Python 3.14, 3.14t, GraalPy, and PyPy 3.11 has been added, while legacy support for Python 3.7, PyPy 3.8/3.9, and CMake <3.15 has been removed. Most deprecated features have been kept for this release, but anything producing a warning in 3.0 may be removed in a future 3.x version. We also now have a deprecation page.

New Features:

  • The smart_holder branch has been merged, enabling py::class_<T, py::smart_holder>, which handles two-way conversion
    with std::unique_ptr<T> and std::shared_ptr<T> (simultaneously), disowning a Python object being passed to std::unique_ptr<T>, trampoline objects, and std::enable_shared_from_this. #5542
  • Changed PYBIND11_MODULE macro implementation to perform multi-phase module initialization (PEP 489) behind the scenes. #5574
  • Support for sub-interpreters (both isolated (with separate GILs) and legacy (with a global GIL). Add the
    py::multiple_interpreters::per_interpreter_gil() tag (or, py::multiple_interpreters::shared_gil() for legacy interpreter
    support) to PYBIND11_MODULE calls (as the third parameter) to indicate that a module supports running with sub-interpreters. #5564
  • Changed PYBIND11_EMBEDDED_MODULE macro implementation to perform multi-phase module initialization (PEP 489) behind the scenes and to support py::mod_gil_not_used(), py::multiple_interpreters::per_interpreter_gil() and py::multiple_interpreters::shared_gil(). #5665 and consolidate code #5670
  • Added API in pybind11/subinterpreter.h for embedding sub-intepreters (requires Python 3.12+). #5666
  • py::native_enum was added, for conversions between Python's native (stdlib) enum types and C++ enums. #5555
    • Add class doc string to py::native_enum. #5617.
    • Fix signature for functions with a native_enum in the signature. #5619
  • A py::release_gil_before_calling_cpp_dtor option (for py::class_) was added to resolve the long-standing issue #1446. #5522
  • Add dtype::normalized_num and dtype::num_of. #5429
  • Add support for array_t<handle> and array_t<object>. #5427
  • Added py::warnings namespace with py::warnings::warn and py::warnings::new_warning_type that provides the interface for
    Python warnings. #5291
  • stl.h list|set|map_caster were made more user friendly: it is no longer necessary to explicitly convert Python iterables to tuple(),
    set(), or map() in many common situations. #4686
  • The array_caster in pybind11/stl.h was enhanced to support value types that are not default-constructible. #5305
  • pybind11/conduit/pybind11_platform_abi_id.h was factored out, to maximize reusability of PYBIND11_PLATFORM_ABI_ID (for other Python/C++ binding systems). #5375
  • Added support for finding pybind11 using pkgconf distributed on pypi. #5552
  • Support --extension-suffix on the pybind11 command. #5360
  • Add semi-public API: pybind11::detail::is_holder_constructed and update example for pybind11::custom_type_setup in documentation. #5669

New Features / fixes (typing):

  • Added option for different arg/return type hints to type_caster. Updated stl/filesystem to use correct arg/return type hints. Updated pybind11::typing to use correct arg/return type hints for nested types. #5450
  • Updated type hint for py::capsule to type.CapsuleType. #5567
  • Adds support for typing.SupportsInt and typing.SupportsFloat. Update Final to be narrower type hint. Make std::function match Callable type. Fix io_name bug in attr_with_type_hint. #5540
  • Rework of arg/return type hints to support .noconvert(). #5486
  • Add attr_with_type for declaring attribute types and Final, ClassVar type annotations. #5460
  • Allow annotate methods with py::pos_only when only have the self argument. Make arguments for auto-generated dunder methods positional-only. #5403
  • Added py::Args and py::KWArgs to enable custom type hinting of *args and **kwargs (see PEP 484). #5357
  • Switched to numpy.typing.NDArray and numpy.typing.ArrayLike. #5212
  • Use numpy.object_ instead of object. #5571
  • Fix module type hint. #5469
  • Fix Buffer type hint. #5662
  • Added support for collections.abc in type hints and convertible checks of STL casters and py::buffer.
    #5566
  • Fix typing and collections.abc type hint ambiguity. #5663

Removals:

  • Remove support for pybind11 v2 internals versions (4, 5, 6). (The internals version number has been bumped for pybind11 v3.) #5512 | #5530
  • Remove make_simple_namespace (added in 2.8.0, deprecated in 2.8.1). #5597
  • Legacy-mode option PYBIND11_NUMPY_1_ONLY has been removed. #5595
  • Add a deprecation warning to .get_type (deprecated in pybind11 2.6 in 2020). #5596

Bug fixes:

  • Set __file__ on submodules. #5584. Except on
    embedded modules. #5650
  • pybind11-bound functions are now pickleable. #5580
  • Fix bug in attr_with_type_hint to allow objects to be in attr_with_type_hint. #5576
  • A -Wmaybe-uninitialized warning suppression was added in pybind11/eigen/matrix.h. #5516
  • PYBIND11_WARNING_POP was incorrectly defined as PYBIND11_PRAGMA(clang diagnostic push). #5448
  • PYBIND11_PLATFORM_ABI_ID (which is used in composing PYBIND11_INTERNALS_ID) was modernized to reflect actual ABI
    compatibility more accurately. #4953 | #5439
  • Fix buffer protocol implementation. #5407
  • Fix iterator increment operator does not skip first item. #5400
  • When getting or deleting an element in a container bound by bind_map, print the key in KeyError if it does not exist. #5397
  • pybind11::builtin_exception is now explicitly exported when linked to libc++. #5390
  • Allow subclasses of py::args and py::kwargs. #5381
  • Disable false-positive GCC 12 Bound Check warning. #5355
  • fix: using __cpp_nontype_template_args instead of __cpp_nontype_template_parameter_class. #5330
  • Properly translate C++ exception to Python exception when creating Python buffer from wrapped object. #5324
  • Update the dict when restoring pickles, instead of assigning a replacement dict. #5658
  • Properly define _DEBUG macro to 1 instead of defining it without value. #5639
  • Fix a missing time cast causing a compile error for newer ICC. #5621
  • Change the behavior of the default constructor of py::slice to be equivalent to :: in Python. #5620

Bug fixes (CMake):

  • Enable FindPython mode by default, with a COMPAT mode that sets some of the old variabl...
Read more

Version 2.13.6

14 Sep 00:33
a2e59f0
Compare
Choose a tag to compare

New Features:

  • A new self._pybind11_conduit_v1_() method is automatically added to all py::class_-wrapped types, to enable type-safe interoperability between different independent Python/C++ bindings systems, including pybind11 versions with different PYBIND11_INTERNALS_VERSION's. Supported on pybind11 2.11.2, 2.12.1, and 2.13.6+. #5296

Bug fixes:

  • Using __cpp_nontype_template_args instead of __cpp_nontype_template_parameter_class. #5330
  • Properly translate C++ exception to Python exception when creating Python buffer from wrapped object. #5324

Documentation:

  • Adds an answer (FAQ) for "What is a highly conclusive and simple way to find memory leaks?". #5340

Version 2.12.1

13 Sep 22:27
Compare
Choose a tag to compare

New Features:

  • A new self._pybind11_conduit_v1_() method is automatically added to all py::class_-wrapped types, to enable type-safe interoperability between different independent Python/C++ bindings systems, including pybind11 versions with different PYBIND11_INTERNALS_VERSION's. Supported on pybind11 2.11.2, 2.12.1, and 2.13.6+. #5296

Version 2.11.2

13 Sep 22:33
Compare
Choose a tag to compare

New Features:

  • A new self._pybind11_conduit_v1_() method is automatically added to all py::class_-wrapped types, to enable type-safe interoperability between different independent Python/C++ bindings systems, including pybind11 versions with different PYBIND11_INTERNALS_VERSION's. Supported on pybind11 2.11.2, 2.12.1, and 2.13.6+. #5296

Version 2.13.5

22 Aug 18:58
7c33cdc
Compare
Choose a tag to compare

Bug fixes:

  • Fix includes when using Windows long paths (\\?\ prefix). #5321
  • Support -Wpedantic in C++20 mode. #5322
  • Fix and test <ranges> support for py::tuple and py::list. #5314

Version 2.13.4

15 Aug 04:11
c6239a8
Compare
Choose a tag to compare

Bug fixes:

  • Fix paths with spaces, including on Windows. (Replaces regression from #5302) #4874

Documentation:

  • Remove repetitive words. #5308

Full Changelog: v2.13.3...v2.13.4

Version 2.13.3

13 Aug 17:36
bd67643
Compare
Choose a tag to compare

Bug fixes:

  • Quote paths from pybind11-config #5302
  • Fix typo in Emscripten support when in config mode (CMake) #5301

Full Changelog: v2.13.2...v2.13.3

Version 2.13.2

13 Aug 13:59
07f3043
Compare
Choose a tag to compare

New Features:

  • A pybind11::detail::type_caster_std_function_specializations feature was added, to support specializations for std::function's with return types that require custom to-Python conversion behavior (to primary use case is to catch and convert exceptions). #4597

Changes:

  • Use PyMutex instead of std::mutex for internal locking in the free-threaded build. #5219
  • Add a special type annotation for C++ empty tuple. #5214
  • When compiling for WebAssembly, add the required exception flags (CMake 3.13+). #5298

Bug fixes:

  • Make gil_safe_call_once_and_store thread-safe in free-threaded CPython. #5246
  • A missing #include <algorithm> in pybind11/typing.h was added to fix build errors (in case user code does not already depend on that include). #5208
  • Fix regression introduced in #5201 for GCC<10.3 in C++20 mode. #5205
  • Remove extra = when assigning flto value in the case for Clang in CMake. #5207

Tests:

  • Adding WASM testing to our CI (Pyodide / Emscripten via scikit-build-core). #4745
  • clang-tidy (in GitHub Actions) was updated from clang 15 to clang 18. #5272

Full Changelog: v2.13.1...v2.13.2

Version 2.13.1

26 Jun 22:36
941f45b
Compare
Choose a tag to compare

New Features:

  • Add support for Typing.Callable[..., T]. #5202

Bug fixes:

  • Avoid aligned allocation in free-threaded build in order to support macOS versions before 10.14. #5200

Version 2.13.0

26 Jun 03:58
0c69e1e
Compare
Choose a tag to compare

New Features:

  • Support free-threaded CPython (3.13t). Add py::mod_gil_not_used() tag to indicate if a module supports running with the GIL disabled. #5148
  • Support for Python 3.6 was removed. (Official end-of-life: 2021-12-23). #5177
  • py::list gained a .clear() method. #5153
  • Support for Union, Optional, type[T], typing.TypeGuard, typing.TypeIs, typing.Never, typing.NoReturn and typing.Literal was added to pybind11/typing.h. #5166 #5165 #5194 #5193 #5192
  • In CMake, if PYBIND11_USE_CROSSCOMPILING is enabled, then CMAKE_CROSSCOMPILING will be respected and will keep pybind11 from accessing the interpreter during configuration. Several CMake variables will be required in this case, but can be deduced from the environment variable SETUPTOOLS_EXT_SUFFIX. The default (currently OFF) may be changed in the future. #5083

Bug fixes:

  • A refcount bug (leading to heap-use-after-free) involving trampoline functions with PyObject * return type was fixed. #5156
  • Return py::ssize_t from .ref_count() instead of int. #5139
  • A subtle bug involving C++ types with unusual operator& overrides was fixed. #5189
  • Support Python 3.13 with minor fix, add to CI. #5127
  • Fix mistake affecting old cmake and old boost. #5149

Documentation:

  • Build docs updated to feature scikit-build-core and meson-python, and updated setuptools instructions. #5168

Tests:

  • Avoid immortal objects in tests. #5150

CI:

Other:

  • Some cleanup in preparation for 3.13 support. #5137
  • Avoid a warning by ensuring an iterator end check is included in release mode. #5129
  • Bump max cmake to 3.29. #5075
  • Update docs and noxfile. #5071