Releases: PyO3/pyo3
PyO3 0.22.1
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
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 RustPartialEq
,PartialOrd
andHash
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 Rustmod
items has been stabilised (and the feature flag removed). The existing implementation of#[pymodule]
onfn
items is still present but soft-deprecated; in the future new features will likely be added only to declarative modules, and thefn
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
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 triggermissing_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
PyO3 0.21.1
This release is a set of touch-ups to PyO3 0.21 to fix cases found as adoption of PyO3 0.21.0 progressed.
The new PyBackedStr
and PyBackedBytes
types have had a large range of standard traits implemented, including Clone
, PartialEq
, Hash
, PartialOrd
, Display
, Debug
, Send
and Sync
.
The argument to a #[setter]
function now accepts the full range of input types as any other function argument in a #[pymethods]
block, and will now correctly handle a #[pyo3(from_py_with = "...")]
annotation.
Some procedural macro output has been adjusted to reuse more code and make it easier to reach complete code coverage in projects using PyO3. The import_exception_bound!
macro has been added to further assist with coverage during migration, by skipping generating code which is only needed to use the exception as a GIL Ref.
Finally, the experimental-async
feature now correctly handles async fn
in #[pymethods]
which have a &self
or &mut self
receiver plus additional arguments.
Thank you to the following users for the improvements:
@alex
@davidhewitt
@geo7
@Icxolu
@reswqa
@rikushoney
@tisonkun
PyO3 0.21.0
This release introduces a substantial new direction for PyO3's API. The Bound<'py, T>
smart pointer type has been added that replaces "GIL Refs" such as &'py PyAny
and &'py PyList
with smart-pointer forms Bound<'py, PyAny>
and Bound<'py, PyList>
. This new smart pointer brings ownership out of PyO3's internals and into user control. This has been done for sake of both performance and soundness.
The migration guide extensively details the intended transition to the new API. To allow users a more graceful upgrade path, PyO3 0.21 and 0.22 will maintain backwards compatibility support for the existing "GIL Refs" API.
As well as the Bound API, highlights of PyO3 0.21 include:
- Support for compiling for GraalPy
- Extended
chrono
/ datetime conversions, including support for theabi3
feature and thechrono-tz
crate - Simplifications to
__next__
and__anext__
methods
PyO3 0.21 also includes two new experimental features:
experimental-async
for a simpleasync fn
integration between Rust and Python.experimental-declarative-modules
for a new simpler#[pymodule]
syntax.
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 users' commits are included in this release:
@acceptacross
@adamreichold
@aldanor
@alex
@alonme
@alxhill
@birkenfeld
@btel
@daemontus
@davidhewitt
@dmatos2012
@Hamatti
@Icxolu
@jadedpasta
@Jerry-Master
@jessekrubin
@Jgfrausing
@juntyr
@kushaldas
@LilyFoote
@maffoo
@mejrs
@messense
@mkovaxx
@neachdainn
@orhun
@samuelcolvin
@snuderl
@suriya-ganesh
@timfel
@Tpt
@wyfo
@Xuanwo
PyO3 0.21.0-beta.0
This release is a prerelease of PyO3 0.21 specifically aimed at confirming the new "Bound" API delivers the expected payoffs to downstream projects and that the migration pathway is manageable.
Some documentation is not yet completely polished, and there are some deprecation warnings which are due to be added. The expectation is that this work will take a week or two at most, and the final 0.21 release will follow at that point.
To read about the new Bound API, best to start with the migration guide entry.
If you test out the new API and have feedback, please open a new GitHub issue or discussion, or reach out on PyO3's new Discord. Feedback in this time period before the final release is particularly appreciated.
A more detailed release announcement and acknowledgements will be written with the final release.
PyO3 0.20.3
This is a stability & compatibility release to fix a couple of minor compilation edge cases from PyO3 0.20.2.
The portable-atomic
dependency has been added to resolve compile failures on platforms without 64-bit atomic support.
A maximum Python version check (currently for Python 3.12) has been added to prevent using old PyO3 code against future Python versions beyond the supported range.
Thank you to the following users for the improvements:
PyO3 0.20.2
This release corrects a failure to compile of the either
feature when the experimental-inspect
feature is not enabled.
It also adds backwards-compatibility for pyo3
0.20.0 to build against pyo3-build-config
0.20.2, as pyo3
0.20.0 was (unintentionally) not pinned against an exact patch version pyo3-build-config
, and pyo3
0.20.0 could not build against pyo3-build-config
0.20.1 due to an internal API adjustment.
Thank you to the following users for the improvements:
PyO3 0.20.1
This release is a maintenance release to resolve a clippy warning which triggers on function arguments of Py<Self>
.
This release also contains a few minor API additions, including optional support for the either
and smallvec
crates.
Thank you to the following users for the improvements:
@adamreichold
@aldanor
@alex
@daemontus
@davidhewitt
@mejrs
@messense
@neachdainn
@orhun
@suriya-ganesh
@wyfo
PyO3 0.20.0
This release is the first PyO3 release to be dual-licensed under Apache 2.0 OR MIT licensing (expanding from just Apache 2.0 of previous releases).
Python 3.12 stable is now supported. The minimum supported Rust version has been increased to Rust 1.56.
The __eq__
, __ne__
, __lt__
, __le__
, __gt__
and __ge__
magic methods are now usable in #[pymethods]
to implement Python operators as an alternative to the __richcmp__
method PyO3 already offered.
#[pyclass(rename_all = "renaming_rule")]
has been added to rename all fields of structs exposed to Python (e.g. rename_all = "snake_case"
) .
PyDict::get_item
now returns Result<Option<&PyAny>>
instead of just Option<&PyAny>
. The previous implementation which ignored Python errors used APIs now considered deprecated by the Python language designers; it is now considered best practice to bubble up any exception raised during dictionary __getitem__
. For most users migration for this change will simply require addition of a ?
on each use of PyDict::get_item
.
Note that Python 3.7 is end of life but PyO3 will continue to support for now as a number of downstream Python packages still have high proportions of downloads on 3.7. A future release is expected to drop Python 3.7 when these numbers reduce.
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 users' commits are included in this release:
@adamreichold
@adriangb
@alex
@BooleanCat
@CallMeMSL
@cdce8p
@DataTriny
@davidhewitt
@ecarrara
@GoldsteinE
@grantslatton
@Hofer-Julian
@ijl
@iliya-malecki
@jakelishman
@jeffs
@juntyr
@krpatter-intc
@lucatrv
@mejrs
@messense
@mhils
@panpilkarz
@puradox
@ringsaturn
@rytheo
@SigureMo
@smheidrich
@Tpt
@youknowone
@zakstucke