github PyO3/pyo3 v0.22.0
PyO3 0.22.0

4 days ago

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

Don't miss a new pyo3 release

NewReleases is sending notifications on new releases.