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:
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 the abi3 feature and the chrono-tz crate
Simplifications to __next__ and __anext__ methods
PyO3 0.21 also includes two new experimental features:
experimental-async for a simple async 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.
Thank you to everyone who contributed code, documentation, design ideas, bug reports, and feedback. The following users' commits are included in this release:
FromPyObject, IntoPy<PyObject> and ToPyObject are implemented on std::duration::Duration#3670
Add PyString::to_cow. Add Py<PyString>::to_str, Py<PyString>::to_cow, and Py<PyString>::to_string_lossy, as ways to access Python string data safely beyond the GIL lifetime. #3677
Add Bound<T> and Borrowed<T> smart pointers as a new API for accessing Python objects. #3686
Add PyNativeType::as_borrowed to convert "GIL refs" to the new Bound smart pointer. #3692
Add FromPyObject::extract_bound method, to migrate FromPyObject implementations to the Bound API. #3706
Add gil-refs feature to allow continued use of the deprecated GIL Refs APIs. #3707
Add methods to PyAnyMethods for binary operators (add, sub, etc.) #3712
Add chrono-tz feature allowing conversion between chrono_tz::Tz and zoneinfo.ZoneInfo#3730
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.3 to 0.21.1.
Release notes
Sourced from pyo3's releases.
... (truncated)
Changelog
Sourced from pyo3's changelog.
... (truncated)
Commits
4168d05
release: 0.21.18cabd26
docs: updates to guide for PyO3 0.21 feedback (#4031)8f87b86
refactor#[setter]
argument extraction (#4002)63ba371
added various std traits forPyBackedStr
andPyBackedBytes
(#4020)336b1c9
addimport_exception_bound!
macro (#4027)3af9a1f
docs: fix example in types.md (#4028)cff4aa3
ci: defer test-debug to the merge queue (#4023)9d932c1
add#[inline]
hints on manyBound
andBorrowed
methods (#4024)22e8dd1
add benchmark for class / method calls (#4016)74d9d23
async method should allow args not only receiver (#4015)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