Skip to content

Releases: PyO3/pyo3

PyO3 0.23.1

16 Nov 23:34
Compare
Choose a tag to compare

This is a re-release of PyO3 0.23.0 with corrections to fix docs.rs builds.

Thanks @yotamofek for the reports & fixes!

PyO3 0.23.0

15 Nov 18:46
c0f756c
Compare
Choose a tag to compare

This release is a significant iteration to both PyO3's internals and API with two major enhancements:

  • Support for Python 3.13t, also known as "free-threaded Python".
  • A new trait IntoPyObject, which unifies the existing to-Python conversion traits IntoPy and ToPyObject while also allowing new optimizations and proper error handling. The new trait also has a #[derive(IntoPyObject)] macro.

While both of these new features have undergone extensive design, it will be no surprise to find teething issues. All feedback is encouraged so that we can follow up with iterative improvements for these new features in future releases.

On top of the major additions, the removal of the "GIL Refs" API deprecated in PyO3 0.21 is now complete. A number of PyO3 APIs have had new simpler names introduced now that the PyO3 API is no longer in a migration phase (for example PyTuple::new_bound is now simplified to PyTuple::new).

Beyond that, PyO3 0.23 contains nearly 5 months of incremental improvements, bug fixes and smaller features that have been implemented while the major work of this release was ongoing.

Please consult the migration guide for help upgrading.

Thank you to everyone who contributed code, documentation, design ideas, bug reports, and feedback. The following contributors' commits are included in this release:

@abrisco
@adamcavendish
@ahlinc
@akuhnregnier
@alex
@attack68
@birkenfeld
@Brogolem35
@bschoenmaeckers
@ChayimFriedman2
@Cheukting
@csernazs
@davidhewitt
@deedy5
@dependabot[bot]
@digitalsentinel
@exg
@FlickerSoul
@gi0baro
@glevco
@Icxolu
@jakelishman
@jeff-k
@jonaspleyer
@JRRudy1
@KLMatlock
@konstin
@LilyFoote
@MatthijsKok
@Mottl
@ngoldbaum
@obi1kenobi
@Owen-CH-Leung
@sansyrox
@shehabgamin
@Stranger6667
@styvane
@Thalyum
@Tlunch
@wangxiaoying
@WilliamTakeshi
@YesSeri
@Zyell

PyO3 0.22.6

05 Nov 22:27
Compare
Choose a tag to compare

This release corrects the check for free-threaded Python introduced in PyO3 0.22.2 to prevent users accidentally installing PyO3 packages on Python 3.13t; PyO3 0.22 does not support free-threaded Python. (Stay tuned for the 0.23 release coming very soon!)

Thanks @minrk for the report and @davidhewitt for the fix!

PyO3 0.22.5

15 Oct 20:59
Compare
Choose a tag to compare

This release fixes a compile regression from 0.22.4 where #[pymethods] with name __clear__ and clear would generate code with a naming conflict. Thanks @awolverp for the report and @Icxolu for the fix!

PyO3 0.22.4

12 Oct 20:58
Compare
Choose a tag to compare

This release is a security fix for PyO3 0.22.0 through 0.22.3.

The PyWeakrefMethods trait functions for reading borrowed values from Python weak references have been identified as unsound, because they did not account for the possibility the last strong reference could be cleared at any time, leading the borrowed value to be dangling and risk of use-after-free.

PyO3 0.22.4 protects against this issue by making these methods permanently leak strong references. The methods are also marked deprecated and will be removed in PyO3 0.23. Users should switch to use the use PyWeakrefMethods functions which return owned references (the deprecation messages indicate the appropriate upgrade paths).

These functions were added in PyO3 0.22.0; all versions from 0.22.0 through 0.22.3 have been yanked.

Aside from the security fix, PyO3 0.22.4 contains a number of other bugfixes, including:

  • A fix for cases where __traverse__ functions of base types were not called when using #[pyclass(extends = ...)]
  • A fix for a regression in 0.22.3 where PyO3 generated code would trigger compile failures with crates using #![forbid(unsafe_code)]

Thank you to the following contributors for the improvements:

@davidhewitt
@ngoldbaum
@exg
@Icxolu

PyO3 0.22.3

15 Sep 20:50
Compare
Choose a tag to compare

This release contains a number of quality improvements building upon PyO3 0.22.2.

Python function calls (using .call0(), .call1(args) and .call(args, kwargs)) will now make use of the "vectorcall" calling conventions where possible, which can reduce overheads in many cases.

There have been several fix-ups to PyO3's FFI definitions. A new pyo3::ffi::compat namespace has been added which offers some backwards-compatible implementations of Python APIs otherwise normally only available on recent Pythons.

There have been numerous other bug-fixes and minor tweaks to improve user experience.

Thank you to the following contributors for the improvements:

@birkenfeld
@ChayimFriedman2
@csernazs
@davidhewitt
@Icxolu
@jakelishman
@LilyFoote
@ngoldbaum
@Zyell

PyO3 0.22.2

17 Jul 21:39
Compare
Choose a tag to compare

This release contains some minor reliability fixes building upon PyO3 0.22.1.

As PyO3 is still working on supporting freethreaded Python (upcoming in 3.13), support has been gated behind an UNSAFE_PYO3_BUILD_FREE_THREADED=1 environment variable to avoid unsuspecting users running into broken builds.

Packages built for the abi3 stable ABI will now use FFI functions for refcounting instead of inline reference count modifications on all versions of the stable ABI (previously only abi3 builds for 3.12 and up would use FFI functions). This helps mitigate interactions of old versions of the stable ABI with future CPython releases which do more complex reference counting (e.g. immortal objects, freethreaded reference counting).

The #[pymodule] declarative module now supports directly receiving options. (E.g. #[pymodule(name = "foo")], which would previously have been written as two attributes #[pymodule] #[pyo3(name = "foo")].)

A compile error on Rust 1.78 related to use of c"" literals has been fixed.

Thank you to the following contributors for the improvements:

@davidhewitt
@FlickerSoul
@gi0baro
@Icxolu
@MatthijsKok
@styvane

PyO3 0.22.1

07 Jul 06:51
59c4fa3
Compare
Choose a tag to compare

This patch release improves some cases related to new functionality in PyO3 0.22.

PartialEq<bool> has been added for Bound<'py, PyBool>.

The #[pyo3(submodule)] attribute has been added for declarative modules to stop submodules from generating an external C symbol for importing the submodule directly (which is typically never used). Declarative modules will also now correctly add items annotated with full-path attributes like #[pyo3::prelude::pyfunction].

The #[pyclass(eq)] option will no longer raise a TypeError on comparison against types not in the signature.

A #[setter] in #[pymethods] with an Option<T> input will no longer raise a deprecation warning.

A regression has been fixed in conversions for 128-bit integers on big-endian platforms.

Thank you to the following contributors for the improvements:

@alex
@davidhewitt
@jatoben
@kylebarron
@musicinmybrain
@ngoldbaum
@Owen-CH-Leung

PyO3 0.22.0

24 Jun 20:13
2e2d440
Compare
Choose a tag to compare

This release introduces support for Python 3.13. Please note that Python 3.13 is still in beta, and while breaking changes are not expected it is very possible that code compiled against Python 3.13 beta versions will be incompatible with the final 3.13 release later in the year.

The minimum supported Rust version has been increased to Rust 1.63.

PyO3's deferred reference counting used to implement Clone for Py<T> without the global interpreter lock has been demonstrated to be impossible to implement safely in the general case and has consequently been changed to panic instead of deferring when cloning Py<T> without the GIL being held. Given the nature of panics inside Clone operations being a potential footgun, this implementation has been moved behind the opt-in py-clone feature.

Other particularly notable changes include:

  • The #[pyclass] macro now has additional options #[pyclass(eq, ord, hash)] to automatically generate Python implementations for equality, ordering and hashing based upon the Rust PartialEq, PartialOrd and Hash traits. This can ensure consistency and reduce boilerplate compared to implementing __eq__, __hash__ and so on manually.
  • The experimental-declarative-modules feature to support #[pymodule] on Rust mod items has been stabilised (and the feature flag removed). The existing implementation of #[pymodule] on fn items is still present but soft-deprecated; in the future new features will likely be added only to declarative modules, and the fn modules may eventually be deprecated and removed.
  • The GIL Refs API deprecation started in PyO3 0.21 continues with all related APIs now being gated behind the gil-refs feature, and unconditionally deprecated. In PyO3 0.23 these APIs are expected to be removed.

There have been numerous other smaller improvements, changes and fixes. For full details see the CHANGELOG.

Please consult the migration guide for help upgrading.

Thank you to everyone who contributed code, documentation, design ideas, bug reports, and feedback. The following contributors' commits are included in this release:

@adamreichold
@alex
@aneeshusa
@birkenfeld
@blmarket
@Cheukting
@cmpute
@codeguru42
@Databean
@davidbrochart
@davidhewitt
@deedy5
@dmatos2012
@Icxolu
@JRRudy1
@lfn3
@liammcinroy
@linhr
@mejrs
@messense
@newcomertv
@reswqa
@sk1p
@SuperJappie08
@Tpt
@wyfo
@xen0n
@Zyell

PyO3 0.21.2

16 Apr 08:07
Compare
Choose a tag to compare

This release contains some fixes to compile-time edge cases for the PyO3 0.21 series:

  • A missing deprecation warning for the GIL Ref constructor PySet::empty has now been added.
  • #[pymodule] functions will no longer trigger missing_docs lints on their generated code.
  • Incorrect implementations of __traverse__ in #[pymethods] will now emit a better error.
  • Extension modules on AIX will now link to libpython.

This release also fixes some compile errors for the experimental-async and experimental-declarative-modules features, and corrects some documentation typos.

Thank you to the following users for the improvements:

@adamreichold
@blmarket
@davidhewitt
@Icxolu
@lfn3
@messense
@wyfo