Releases: pybind/pybind11
Version 3.0.1
Bug fixes:
- Fixed compilation error in
type_caster_enum_typewhen casting pointer-to-enum types. Added pointer overload to handle dereferencing before enum conversion. #5776 - Implement binary version of
make_index_sequenceto reduce template depth requirements for functions with many parameters. #5751 - Subinterpreter-specific exception handling code was removed to resolve segfaults. #5795
- Fixed issue that caused
PYBIND11_MODULEcode to run again if the module was re-imported after being deleted fromsys.modules. #5782 - Prevent concurrent creation of sub-interpreters as a workaround for stdlib concurrency issues in Python 3.12. #5779
- Fixed potential crash when using
cpp_functionobjects with sub-interpreters. #5771 - Fixed non-entrant check in
implicitly_convertible(). #5777 - Support C++20 on platforms that have older c++ runtimes. #5761
- Fix compilation with clang on msys2. #5757
- Avoid
nullptrdereference warning with GCC 13.3.0 and python 3.11.13. #5756 - Fix potential warning about number of threads being too large. #5807
- Fix gcc 11.4+ warning about serial compilation using CMake. #5791
Documentation:
- Improve
buffer_infotype checking in numpy docs. #5805 - Replace
robotpy-buildwithsemiwrapin the binding tool list. #5804 - Show nogil in most examples. #5770
- Fix
py::trampoline_self_life_supportvisibility in docs. #5766
Tests:
- Avoid a spurious warning about
DOWNLOAD_CATCHbeing manually specified. #5803 - Fix an IsolatedConfig test. #5768
CI:
- Add CI testing for Android. #5714
Internal:
- Rename internal variables to avoid the word
slots(reads better). #5793
Version 3.0.0
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_holderbranch has been merged, enablingpy::class_<T, py::smart_holder>, which handles two-way conversion withstd::unique_ptr<T>andstd::shared_ptr<T>(simultaneously), disowning a Python object being passed tostd::unique_ptr<T>, trampoline objects, andstd::enable_shared_from_this. #5542-
Added support for
std::shared_ptr<const T>inpy::init()when usingpy::smart_holder, complementing existing support forstd::unique_ptr<const T>. #5731 -
Support const-only smart pointers. #5718
-
Eliminate cross-DSO RTTI reliance from
trampoline_self_life_supportfunctionality,smart_holderdeleter detection, and othersmart_holderbookkeeping. Resolves platform-specific issues on macOS related to cross-DSOdynamic_castandtypeidmismatches. #5728 (replaces #5700)
-
-
Changed
PYBIND11_MODULEmacro implementation to perform multi-phase module initialization (PEP 489) behind the scenes. #5574 and avoid destruction #5688 -
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) toPYBIND11_MODULEcalls (as the third parameter) to indicate that a module supports running with sub-interpreters. #5564-
Rename macro
PYBIND11_SUBINTERPRETER_SUPPORT->PYBIND11_HAS_SUBINTERPRETER_SUPPORTto meet naming convention. #5682 -
Allow subinterpreter support to be disabled if defined to 0. This is mostly an emergency workaround, and is not exposed in CMake. #5708 and #5710
-
Modify internals pointer-to-pointer implementation to not use
thread_local(better iOS support). #5709 -
Support implementations without subinterpreter support. #5732
-
-
Changed
PYBIND11_EMBEDDED_MODULEmacro implementation to perform multi-phase module initialization (PEP 489) behind the scenes and to supportpy::mod_gil_not_used(),py::multiple_interpreters::per_interpreter_gil()andpy::multiple_interpreters::shared_gil(). #5665 and consolidate code #5670 -
Added API in
pybind11/subinterpreter.hfor embedding sub-intepreters (requires Python 3.12+). #5666 -
py::native_enumwas added, for conversions between Python's native (stdlib) enum types and C++ enums. #5555 -
Support
py::numpy_scalar<>/py::make_scalar()for NumPy types. #5726 -
A
py::release_gil_before_calling_cpp_dtoroption (forpy::class_) was added to resolve the long-standing issue #1446. #5522 -
Add
dtype::normalized_numanddtype::num_of. #5429 -
Add support for
array_t<handle>andarray_t<object>. #5427 -
Added
py::warningsnamespace withpy::warnings::warnandpy::warnings::new_warning_typethat provides the interface for Python warnings. #5291 -
stl.hlist|set|map_casterwere made more user friendly: it is no longer necessary to explicitly convert Python iterables totuple(),set(), ormap()in many common situations. #4686 -
The
array_casterin pybind11/stl.h was enhanced to support value types that are not default-constructible. #5305 -
pybind11/conduit/pybind11_platform_abi_id.hwas factored out, to maximize reusability ofPYBIND11_PLATFORM_ABI_ID(for other Python/C++ binding systems). Separately, a note was added to explain that the conduit feature only covers from-Python-to-C++ conversions. #5375 | #5740 -
Added support for finding pybind11 using pkgconf distributed on pypi. #5552
-
Support
--extension-suffixon the pybind11 command. #5360 -
Add semi-public API:
pybind11::detail::is_holder_constructedand update example forpybind11::custom_type_setupin documentation. #5669 -
Added
py::scoped_critical_sectionto support free-threaded mode. #5684 | #5706
New Features / fixes (typing):
-
Added option for different arg/return type hints to
type_caster. Updatedstl/filesystemto use correct arg/return type hints. Updatedpybind11::typingto use correct arg/return type hints for nested types. #5450 -
Updated type hint for
py::capsuletotype.CapsuleType. #5567 -
Adds support for
typing.SupportsIntandtyping.SupportsFloat. UpdateFinalto be narrower type hint. Makestd::functionmatchCallabletype. Fixio_namebug inattr_with_type_hint. #5540 -
Rework of arg/return type hints to support
.noconvert(). #5486 -
Add
attr_with_typefor declaring attribute types andFinal,ClassVartype annotations. #5460 -
Allow annotate methods with
py::pos_onlywhen only have theselfargument. Make arguments for auto-generated dunder methods positional-only. #5403 -
Added
py::Argsandpy::KWArgsto enable custom type hinting of*argsand**kwargs(see PEP 484). #5357 -
Switched to
numpy.typing.NDArrayandnumpy.typing.ArrayLike. #5212 -
Use
numpy.object_instead ofobject. #5571 -
Fix module type hint. #5469
-
Fix Buffer type hint. #5662
-
Added support for
collections.abcin type hints and convertible checks of STL casters andpy::buffer. #5566 -
Fix
typingandcollections.abctype hint ambiguity. #5663 -
Add
typing_extensionsalternatives for all types that need them. #5693
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_ONLYhas 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_hintto allow objects to be inattr_with_type_hint. #5576 -
A
-Wmaybe-uninitializedwarning suppression was added inpybind11/eigen/matrix.h. #5516 -
PYBIND11_WARNING_POPwas incorrectly defined asPYBIND11_PRAGMA(clang diagnostic push). #5448 -
PYBIND11_PLATFORM_ABI_ID(which is used in composingPYBIND11_INTERNALS_ID) was modernized to reflect actual ABI compatibility more accurately. #4953 | [#5439](https://github.com...
Version 3.0.0 RC 4
What's Changed
- feat: numpy scalars by @henryiii in #5726
- fix: TSan warning in sub-interpreter test by @b-pass in #5729
- fix: add support for
shared_ptr<const T>inpy::init()withsmart_holderby @rwgk in #5731 - fix: add support for const-only smart pointers by @Rosdf in #5718
- fix: android CMake support by @henryiii in #5733
- fix: eliminate cross-DSO RTTI reliance in
smart_holderfunctionality (for platforms like macOS). by @rwgk in #5728 - fix: handle implementations without subinterpreter support by @msimacek in #5732
- ci: avoid 3.13.4 on Windows by @henryiii in #5725
- ci: check latest on 3.13 by @henryiii in #5734
- ci: cibw update to 3.0.0rc2 by @henryiii in #5717
- docs: Add documentation entry for warnings by @jiwaszki in #5356
- tests: better test for const only smart ptr by @Rosdf in #5727
- tests: run pytest under Python devmode by @XuehaiPan in #5715
- chore(deps): bump pypa/cibuildwheel from 3.0.0rc2 to 3.0 in the actions group by @dependabot in #5721
- chore(deps): bump requests from 2.32.3 to 2.32.4 in /docs by @dependabot in #5720
- chore(deps): bump urllib3 from 2.2.2 to 2.5.0 in /docs by @dependabot in #5735
- chore: prepare for 3.0.0rc4 by @henryiii in #5736
Important
This RC has an ABI bump. This is expected to be the last bump (and last RC) unless something comes up.
New Contributors
Full Changelog: v3.0.0rc3...v3.0.0rc4
Version 3.0.0 RC 3
This is another release candidate. See the changelog in the docs for the combined changelog; this is just the changes since RC 2:
- fix(types): type hints from future python versions by @InvincibleRMC in #5693
- fix: allow subinterpreters to be manually disabled by @henryiii in #5708
- fix: follow rest of pybind11 closer with
PYBIND11_HAS_SUBINTERPRETER_SUPPORTby @henryiii in #5710 - fix: modify the internals pointer-to-pointer implementation to not use
thread_localby @b-pass in #5709 - fix: expose required symbol using clang by @petersteneteg in #5700
- fix: handle null
py::handleand add tests forpy::scoped_critical_sectionby @XuehaiPan in #5706 - ci: avoid brownout (and removal) of windows-2019 by @henryiii in #5712
- ci: ios by @henryiii in #5705
- ci: reduced runs on draft PRs by @henryiii in #5707
- docs: prepare for RC 3 by @henryiii in #5713
Warning
Note our iOS support requires a cibuildwheel 3.0 beta currently, the cibuildwheel v3.0.0rc1 does not work.
Important
This RC has an ABI bump. We might need one more ABI bump before 3.0 final to improve the protection of our internals.
New Contributors
- @petersteneteg made their first contribution in #5700
Full Changelog: v3.0.0rc2...v3.0.0rc3
Version 3.0.0 RC 2
This is another release candidate. See the changelog in the docs for the combined changelog; this is just the changes since RC 1:
- feat: scoped_critical_section by @henryiii in #5684
- fix(cmake): regression in include guard by @henryiii in #5691
- fix: don't destruct module objects in atexit by @b-pass in #5688
- fix: prepare for 3.14 beta 2 by @henryiii in #5697
- chore(cmake): add compile commands to preset by @henryiii in #5685
- chore: bump maximum clang tested to 20 by @henryiii in #5692
- chore: rename macro
PYBIND11_SUBINTERPRETER_SUPPORT->PYBIND11_HAS_SUBINTERPRETER_SUPPORTto meet naming convention by @XuehaiPan in #5682 - chore: use CPython macros to construct
PYBIND11_VERSION_HEXby @XuehaiPan in #5683 - docs: more warnings about locking and the GIL by @henryiii in #5689
- docs: update contributing/release guide a little by @henryiii in #5681
- tests: always disable on the nogil build by @henryiii in #5701
- tests: expect free-threaded import warnings by @henryiii in #5680
- tests: skip some flaky gil tests on nogil by @henryiii in #5699
Full Changelog: v3.0.0rc1...v3.0.0rc2
Version 3.0.0 RC 1
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_holderbranch has been merged, enablingpy::class_<T, py::smart_holder>, which handles two-way conversion
withstd::unique_ptr<T>andstd::shared_ptr<T>(simultaneously), disowning a Python object being passed tostd::unique_ptr<T>, trampoline objects, andstd::enable_shared_from_this. #5542 - Changed
PYBIND11_MODULEmacro 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) toPYBIND11_MODULEcalls (as the third parameter) to indicate that a module supports running with sub-interpreters. #5564 - Changed
PYBIND11_EMBEDDED_MODULEmacro implementation to perform multi-phase module initialization (PEP 489) behind the scenes and to supportpy::mod_gil_not_used(),py::multiple_interpreters::per_interpreter_gil()andpy::multiple_interpreters::shared_gil(). #5665 and consolidate code #5670 - Added API in
pybind11/subinterpreter.hfor embedding sub-intepreters (requires Python 3.12+). #5666 py::native_enumwas added, for conversions between Python's native (stdlib) enum types and C++ enums. #5555- A
py::release_gil_before_calling_cpp_dtoroption (forpy::class_) was added to resolve the long-standing issue #1446. #5522 - Add
dtype::normalized_numanddtype::num_of. #5429 - Add support for
array_t<handle>andarray_t<object>. #5427 - Added
py::warningsnamespace withpy::warnings::warnandpy::warnings::new_warning_typethat provides the interface for
Python warnings. #5291 stl.hlist|set|map_casterwere made more user friendly: it is no longer necessary to explicitly convert Python iterables totuple(),
set(), ormap()in many common situations. #4686- The
array_casterin pybind11/stl.h was enhanced to support value types that are not default-constructible. #5305 pybind11/conduit/pybind11_platform_abi_id.hwas factored out, to maximize reusability ofPYBIND11_PLATFORM_ABI_ID(for other Python/C++ binding systems). #5375- Added support for finding pybind11 using pkgconf distributed on pypi. #5552
- Support
--extension-suffixon the pybind11 command. #5360 - Add semi-public API:
pybind11::detail::is_holder_constructedand update example forpybind11::custom_type_setupin documentation. #5669
New Features / fixes (typing):
- Added option for different arg/return type hints to
type_caster. Updatedstl/filesystemto use correct arg/return type hints. Updatedpybind11::typingto use correct arg/return type hints for nested types. #5450 - Updated type hint for
py::capsuletotype.CapsuleType. #5567 - Adds support for
typing.SupportsIntandtyping.SupportsFloat. UpdateFinalto be narrower type hint. Makestd::functionmatchCallabletype. Fixio_namebug inattr_with_type_hint. #5540 - Rework of arg/return type hints to support
.noconvert(). #5486 - Add
attr_with_typefor declaring attribute types andFinal,ClassVartype annotations. #5460 - Allow annotate methods with
py::pos_onlywhen only have theselfargument. Make arguments for auto-generated dunder methods positional-only. #5403 - Added
py::Argsandpy::KWArgsto enable custom type hinting of*argsand**kwargs(see PEP 484). #5357 - Switched to
numpy.typing.NDArrayandnumpy.typing.ArrayLike. #5212 - Use
numpy.object_instead ofobject. #5571 - Fix module type hint. #5469
- Fix Buffer type hint. #5662
- Added support for
collections.abcin type hints and convertible checks of STL casters andpy::buffer.
#5566 - Fix
typingandcollections.abctype 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_ONLYhas 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_hintto allow objects to be inattr_with_type_hint. #5576 - A
-Wmaybe-uninitializedwarning suppression was added inpybind11/eigen/matrix.h. #5516 PYBIND11_WARNING_POPwas incorrectly defined asPYBIND11_PRAGMA(clang diagnostic push). #5448PYBIND11_PLATFORM_ABI_ID(which is used in composingPYBIND11_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 inKeyErrorif it does not exist. #5397 pybind11::builtin_exceptionis now explicitly exported when linked to libc++. #5390- Allow subclasses of
py::argsandpy::kwargs. #5381 - Disable false-positive GCC 12 Bound Check warning. #5355
- fix: using
__cpp_nontype_template_argsinstead 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
_DEBUGmacro to1instead 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::sliceto be equivalent to::in Python. #5620
Bug fixes (CMake):
- Enable FindPython mode by default, with a
COMPATmode that sets some of the old variabl...
Version 2.13.6
New Features:
- A new
self._pybind11_conduit_v1_()method is automatically added to allpy::class_-wrapped types, to enable type-safe interoperability between different independent Python/C++ bindings systems, including pybind11 versions with differentPYBIND11_INTERNALS_VERSION's. Supported on pybind11 2.11.2, 2.12.1, and 2.13.6+. #5296
Bug fixes:
- Using
__cpp_nontype_template_argsinstead 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
New Features:
- A new
self._pybind11_conduit_v1_()method is automatically added to allpy::class_-wrapped types, to enable type-safe interoperability between different independent Python/C++ bindings systems, including pybind11 versions with differentPYBIND11_INTERNALS_VERSION's. Supported on pybind11 2.11.2, 2.12.1, and 2.13.6+. #5296
Version 2.11.2
New Features:
- A new
self._pybind11_conduit_v1_()method is automatically added to allpy::class_-wrapped types, to enable type-safe interoperability between different independent Python/C++ bindings systems, including pybind11 versions with differentPYBIND11_INTERNALS_VERSION's. Supported on pybind11 2.11.2, 2.12.1, and 2.13.6+. #5296