Skip to content

Releases: PyO3/pyo3

PyO3 0.28.0

01 Feb 22:31
f0c1523

Choose a tag to compare

This release contains many improvements across PyO3's feature set:

  • Proper support for __init__ methods for #[pyclass] types
  • Support for #[deleter]s to complement the existing #[getter] and #[setter] attributes when implementing class "properties".
  • Support for subclassing many Python types with the abi3 feature (requires Python 3.12+).
  • A new #[pyclass(new = "from_fields")] option to automatically define the constructor from the class fields.
  • Many corrections to FFI definitions (including removal of many private CPython methods)
  • Many improvements to the experimental-inspect feature's functionality.

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

This release also switches #[pymodule] to use PEP 489 multi-phase initialization internally. This should have no immediate functional impact other than preparing PyO3 to support newer technologies such as Python subinterpreters.

There are also many other incremental improvements, bug fixes and smaller features; full detail can be found in 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:

@ABorgna
@ahlinc
@alex
@altendky
@bazaah
@bschoenmaeckers
@chirizxc
@clin1234
@davidhewitt
@dependabot[bot]
@freakboy3742
@henryp3278
@Icxolu
@lazka
@LilyFirefly
@linkmauve
@lmmx
@lukaslueg
@MatthieuDartiailh
@MusicalNinjaDad
@ngoldbaum
@pkalivas
@reaperhulk
@RedKinda
@SilasMarvin
@SoroushMoosapour
@stijndcl
@tpoliaw
@Tpt

PyO3 0.27.2

30 Nov 09:22

Choose a tag to compare

This patch contains very minor fixes for the PyO3 0.27 series:

  • Workaround a rustc 1.92+ crash compiling PyO3 with both debug assertions and optimizations enabled.
  • Fix runtime crash when subclassing dicts on PyPy and GraalPy.

There are also a number of documentation improvements applied across the codebase.

Thank you to the following contributors for the improvements:

@davidhewitt
@dependabot[bot]
@MusicalNinjaDad
@pkalivas
@tpoliaw
@Tpt

PyO3 0.27.1

21 Oct 20:40

Choose a tag to compare

This release fixes a clippy lint regression in PyO3 0.27.0, and exposes the PySendResult type (the return value from Bound<PyIterator>::send).

Thank you to the following contributors for the improvements:

@alex
@davidhewitt
@reaperhulk
@tpoliaw

PyO3 0.27.0

19 Oct 11:17
7525512

Choose a tag to compare

This release is the first PyO3 release to be tested against Python 3.14.0 final. There are no significant changes to 3.14 support since PyO3 0.26 which was tested against the 3.14 release candidates.

Support for PyPy 3.9 and PyPy 3.10 (both no longer supported upstream) has been dropped.

The FromPyObject trait has been reworked in a similar fashion to the IntoPyObject trait introduced in PyO3 0.23. This has established a performant and flexible implementation of both these traits and no further changes to the traits are anticipated in the future. Thank you for the patience upgrading through these incremental improvements at the core of PyO3.

The .downcast() family of functions are now deprecated in favour of the .cast() family of functions, which are an incremental improvement to API usability and to error messages on failed conversions.

Operations on the PyCapsule type have been changed without deprecation to fix some issues with lifetimes of return values (in .name() and .reference() specifically). The capsule API now also encourages checking of capsule names, which is one of the few defences available to protect the validity of casting data read by the capsule API.

There are also many other incremental improvements, bug fixes and smaller features.

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:

@alex
@altendky
@bazaah
@bschoenmaeckers
@crepererum
@davidhewitt
@dependabot[bot]
@elbaro
@Icxolu
@jqnatividad
@mbrobbel
@NilsIrl
@rvben
@sanders41
@tdyas
@Tpt
@vvsagar

PyO3 0.26.0

29 Aug 13:41
4502c2e

Choose a tag to compare

This version solidifies support for Python 3.14 and free-threaded Python 3.14t. A number of PyO3 APIs have been renamed to reflect the fact the GIL is no longer a universal feature of all Python implementations. For example:

  • Python::with_gil is now known as Python::attach
  • Python::allow_threads is now known as Python::detach
  • pyo3::prepare_freethreaded_python is now known as Python::initialize()

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

An optional dependency on the bytes crate has been added to allow support for converting bytes::Bytes to / from Python.

The PyObject type alias for Py<PyAny> has also been deprecated; the Py and Bound smart pointers have been the primary interface for all Python-facing types since PyO3 0.21 and the PyObject type alias had been a frequent source of confusion.

There are also many other incremental improvements, bug fixes and smaller features.

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:

@ahlinc
@alex
@anilbey
@bschoenmaeckers
@Cheukting
@codeguru42
@davidhewitt
@decathorpe
@dependabot[bot]
@drewkett
@FlickerSoul
@Icxolu
@jder
@jessekrubin
@jjmarchewitz
@kemingy
@msimacek
@musicinmybrain
@ngoldbaum
@Nnamdi-sys
@nucccc
@olp-cs
@robsdedude
@rrricharrrd
@sxlijin
@timfel
@tonybaloney
@Tpt
@wxianxin
@xushiyan
@yogevm15

PyO3 0.25.1

12 Jun 21:19

Choose a tag to compare

This release adds testing for arm64 Windows, and fixes a bug with Python 3.14 support on 32-bit systems.

This release also adds a chrono-local feature to enable support for chrono::Local timezone (this was previously available in PyO3 0.24 but would convert the local timezone to a fixed offset, which did not round-trip well).

There are a few other fixes, mostly correcting FFI definitions and improving compiler errors when writing async code without the experimental-async feature enabled.

Thank you to the following contributors for the improvements:

@bschoenmaeckers
@Cheukting
@davidhewitt
@decathorpe
@dependabot[bot]
@Icxolu
@jessekrubin
@musicinmybrain
@ngoldbaum
@timfel
@tonybaloney
@Tpt
@yogevm15

PyO3 0.25.0

14 May 11:36
ec1a350

Choose a tag to compare

This version extends Python version support to include the new Python 3.14, currently in beta. Please note it is possible that there may yet be changes to 3.14 before stable release which may impact final compatibility.

New optional dependencies on bigdecimal, ordered_float, and time have been added to permit converting types from those crates to Python types (and vice versa).

The experimental-inspect feature now has the capability to autogenerate type stubs. These stubs are still extremely basic and lack much information. Tooling such as setuptools-rust and maturin will also need to be updated to make adoption of these easier. Please follow #5137 to keep abreast of developments of this feature.

The #[pyclass] macro has gained new options #[pyclass(generic)] and #[pyclass(immutable_type)] to offer additional control over the runtime behaviour of the generated Python type object.

The AsPyPointer trait has been removed as PyO3's smart pointer types such as Py<T>, Bound<T> and Borrowed<T> covered this use case with a better API.

As part of the upgrade to support 3.14, there have also been many cleanups to pyo3-ffi. Many definitions which are private implementation details of CPython have been removed; projects downstream of CPython cannot rely on stability of these even across CPython patch releases.

There are also many other incremental improvements, bug fixes and smaller features.

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:

@0x676e67
@bschoenmaeckers
@clin1234
@davidbrochart
@davidhewitt
@ddelange
@decathorpe
@dependabot[bot]
@exg
@hgmich
@Icxolu
@IvanIsCoding
@m-ou-se
@n-eq
@ngoldbaum
@Owen-CH-Leung
@prutschman-iv
@superserious-dev
@Tpt
@trim21
@Vrajs16
@xhochy

PyO3 0.24.2

21 Apr 21:27

Choose a tag to compare

This is a small patch release containing minor bugfixes and documentation improvements, including an unused imports lint warning raised from inside PyO3's proc macros.

Thank you to the following contributors for the improvements:

@davidbrochart
@davidhewitt
@ddelange
@decathorpe
@hgmich
@Icxolu
@n-eq
@Tpt
@trim21

PyO3 0.24.1

01 Apr 08:26
a213b36

Choose a tag to compare

This release is a security fix for the PyString::from_object method, which passed &str data to the Python C API without checking for a terminating nul byte. All historical PyO3 versions are affected, and we recommend you upgrade if you are using PyString::from_object. Thank you to @vthib for the report and @Dr-Emann for the fix. A RUSTSEC advisory will be published shortly.

Aside from the security fix, this release contains a number of other non-breaking additions:

  • An abi3-py313 feature to support compiling with the Python 3.13 stable ABI.
  • PyAnyMethods::getattr_opt to get optional attributes without paying the cost of a Python exception when the attribute in question does not exist.
  • Constructor for PyInt::new.
  • with_critical_section2 for locking two objects at the same time on the free-threaded build.
  • Fix for a PyO3 0.24.0 regression with Option<&str> and Option<&T> (where T: PyClass) function arguments no longer being permitted

There are also a few other small bug fixes for edge cases, mostly related to compile errors from PyO3's macro code.

Thank you to the following contributors for the improvements:

@bschoenmaeckers
@davidhewitt
@Dr-Emann
@emmagordon
@epontan
@Icxolu
@IvanIsCoding
@jelmer
@jonaspleyer
@ngoldbaum
@Owen-CH-Leung
@Tpt
@Trolldemorted
@XuehaiPan

PyO3 0.24.0

09 Mar 23:14
059e249

Choose a tag to compare

This release is an incremental improvement of refinements and optimizations following the new APIs established in PyO3's last few releases.

Support for jiff datetime conversions have been added, and also UUID conversions.

The FromPyObject derive macro has gained new #[pyo3(default = ...)] and #[pyo3(rename_all = ...)] options, and the IntoPyObject derive macro has gained a new #[pyo3(into_py_with = ...)] option.

PyO3 will now pass positional arguments to Python functions using the "vectorcall" protocol in many cases, which should be an optimization over the previous behaviour (of creating a Python tuple of positional arguments).

Many methods on iterators of Python collections have been optimized.

There are also many other incremental improvements, bug fixes and smaller features.

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

@0x676e67
@alex
@arielb1
@bschoenmaeckers
@davidhewitt
@dependabot[bot]
@eltociear
@Icxolu
@IvanIsCoding
@JeanArhancet
@kahojyun
@kemingy
@kylebarron
@LifeLex
@LilyFoote
@lundybernard
@matt-codecov
@mattip
@mejrs
@messense
@msimacek
@ngoldbaum
@nicolasavru
@Owen-CH-Leung
@peterjoel
@SilverBzH
@Tpt
@yoav-orca
@yotamofek