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:
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:
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.
Fix compile failure in declarative #[pymodule] under presence of #![no_implicit_prelude]. #4328
Fix use of borrowed reference in PyDict::get_item (unsafe in free-threaded Python). #4355
Fix #[pyclass(eq)] macro hygiene issues for structs and enums. #4359
Fix hygiene/span issues of '#[pyfunction] and #[pymethods] generated code which affected expansion in macro_rules context. #4382
Fix unsafe_code lint error in #[pyclass] generated code. #4396
Fix async functions returning a tuple only returning the first element to Python. #4407
Fix use of borrowed reference in PyList::get_item (unsafe in free-threaded Python). #4410
Correct FFI definition PyArg_ParseTupleAndKeywords to take *const *const c_char instead of *mut *mut c_char on Python 3.13 and up. #4420
Fix a soundness bug with PyClassInitializer: panic if adding subclass to existing instance via PyClassInitializer::from(Py<BaseClass>).add_subclass(SubClass). #4454
Fix illegal reference counting op inside implementation of __traverse__ handlers. #4479
[0.22.2] - 2024-07-17
Packaging
Require opt-in to freethreaded Python using the UNSAFE_PYO3_BUILD_FREE_THREADED=1 environment variable (it is not yet supported by PyO3). #4327
Changed
Use FFI function calls for reference counting on all abi3 versions. #4324
#[pymodule(...)] now directly accepts all relevant #[pyo3(...)] options. #4330
Fixed
Fix compile failure in declarative #[pymodule] under presence of #![no_implicit_prelude]. #4328
Fix compile failure due to c-string literals on Rust < 1.79. #4353
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Bumps pyo3 from 0.20.2 to 0.22.3.
Release notes
Sourced from pyo3's releases.
... (truncated)
Changelog
Sourced from pyo3's changelog.
... (truncated)
Commits
cd5369c
release: 0.22.3f38c43a
revert removal of_Py_XNewRef
and_Py_NewRef
in 0.22 linedbb33ad
ci: fixup abi3 ui test outputee3b73f
ci: updates for Rust 1.81 (#4533)146c397
ci: fix nightly warning about unreachable pattern (#4437)08a1630
type_object: fix new clippy complaint about length of doc comment (#4527)6c54632
fix beta/nightly ci (#4549)560790b
fix nightly ci (#4385)2c66281
ci: fix diagnostic case with abi366ac6c7
fix ui tests (#4397)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show