-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update pyo3 to v0.22 and update code to use pyo3 Bound
types
#123
Conversation
7453b83
to
485d840
Compare
d827943
to
1382fdc
Compare
d9dcac9
to
fc405c7
Compare
6daa2c5
to
45c53cb
Compare
45c53cb
to
1a0ff79
Compare
1a0ff79
to
2ce1dcb
Compare
2ce1dcb
to
1bd86b9
Compare
1bd86b9
to
4176751
Compare
4176751
to
5ee7b62
Compare
Mainly we adjust usages of the GIL refs API to `Bound<T>`.
Edited/Blocked NotificationRenovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. You can manually request rebase by checking the rebase/retry box above. |
This comment was marked as outdated.
This comment was marked as outdated.
Benchmark for a45137cClick to view benchmark
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested updated module with Commodore/Kapitan, everything still works fine
Bound
types
This PR contains the following updates:
=0.20.3
->=0.22.2
Release Notes
pyo3/pyo3 (pyo3)
v0.22.2
: PyO3 0.22.2Compare Source
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 onlyabi3
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:
@davidhewitt
@FlickerSoul
@gi0baro
@Icxolu
@MatthijsKok
@styvane
v0.22.1
Compare Source
Added
#[pyo3(submodule)]
option for declarative#[pymodule]
s. #4301PartialEq<bool>
forBound<'py, PyBool>
. #4305Fixed
NotImplemented
instead of raisingTypeError
from generated equality method when comparing different types. #4287#[pyo3::prelude::pymodule]
and similar for#[pyclass]
and#[pyfunction]
in declarative modules.#4288#[setter]
function. #4304v0.22.0
Compare Source
Packaging
heck
dependency to 0.5. #3966chrono-tz
optional dependency to include version 0.10. #4061num-rational
feature to add conversions with Python'sfractions.Fraction
. #4148Added
PyWeakref
,PyWeakrefReference
andPyWeakrefProxy
. #3835#[pyclass]
on enums that have tuple variants. #4072Decimal
conversion. #4079pyo3_disable_reference_pool
conditional compilation flag to avoid the overhead of the global reference pool at the cost of known limitations as explained in the performance section of the guide. #4095#[pyo3(constructor = (...))]
to customize the generated constructors for complex enum variants. #4158PyType::module
, which always matches Python__module__
. #4196PyType::fully_qualified_name
which matches the "fully qualified name" defined in PEP 737. #4196PyTypeMethods::mro
andPyTypeMethods::bases
. #4197#[pyclass(ord)]
to implement ordering based onPartialOrd
. #4202ToPyObject
andIntoPy<PyObject>
forPyBackedStr
andPyBackedBytes
. #4205#[pyclass(hash)]
option to implement__hash__
in terms of theHash
implementation #4206#[pyclass(eq)]
option to generate__eq__
based onPartialEq
, and#[pyclass(eq_int)]
for simple enums to implement equality based on their discriminants. #4210From<Bound<'py, T>>
forPyClassInitializer<T>
. #4214as_super
methods toPyRef
andPyRefMut
for accesing the base class by reference. #4219PartialEq<str>
forBound<'py, PyString>
. #4245PyModuleMethods::filename
on PyPy. #4249PartialEq<[u8]>
forBound<'py, PyBytes>
. #4250pyo3_ffi::c_str
macro to create&'static CStr
on Rust versions which don't have 1.77'sc""
literals. #4255bool
conversion withnumpy
2.0'snumpy.bool
type #4258PyAnyMethods::{bitnot, matmul, floor_div, rem, divmod}
. #4264Changed
PySliceIndices::slicelength
and thelength
parameter ofPySlice::indices()
. #3761Clone
ing pointers into the Python heap has been moved behind thepy-clone
feature, as it must panic without the GIL being held as a soundness fix. #4095#[track_caller]
to allPy<T>
,Bound<'py, T>
andBorrowed<'a, 'py, T>
methods which can panic. #4098PyAnyMethods::dir
to be fallible and returnPyResult<Bound<'py, PyList>>
(and similar forPyAny::dir
). #4100weakref
ordict
when compiling forabi3
for Python older than 3.9. #4194PyType::name
to always match Python__name__
. #4196#[pyclass(eq_int)]
. #4210module=
attribute of declarative modules' child#[pymodule]
s and#[pyclass]
es. #4213module
option for complex enum variants from the value set on the complex enummodule
. #4228abi3
feature on PyPy or GraalPy. #4237#[pyo3(get)]
on#[pyclass]
fields. #4254PyCFunction::new
,PyCFunction::new_with_keywords
andPyCFunction::new_closure
now take&'static CStr
name and doc arguments (previously was&'static str
). #4255experimental-declarative-modules
feature is now stabilized and available by default. #4257Fixed
PYO3_CROSS_LIB_DIR
is set to a missing path. #4043create_exception!
living in a different Rust module using thedeclarative-module
feature. #4086PY_VECTORCALL_ARGUMENTS_OFFSET
andPyVectorcall_NARGS
to fix a false-positive assertion. #4104PyUnicode_DATA
on PyPy: not exposed by PyPy. #4116#[pyo3(from_py_with = ...)]
attribute on dunder (__magic__
) method arguments instead of silently ignoring it. #4117mod
node. #4236__dict__
attribute missing for#[pyclass(dict)]
instances when building forabi3
on Python 3.9. #4251v0.21.2
Compare Source
Changed
PySet::empty()
gil-ref constructor. #4082Fixed
async fn
in#[pymethods]
with a&self
receiver and more than one additional argument. #4035__traverse__
. #4045#[pyclass]
living in a different Rust module using theexperimental-declarative-modules
feature. #4054missing_docs
lint triggering on documented#[pymodule]
functions. #4067libpython
). #4073v0.21.1
Compare Source
Added
Send
andSync
forPyBackedStr
andPyBackedBytes
. #4007Clone
,Debug
,PartialEq
,Eq
,PartialOrd
,Ord
andHash
implementation forPyBackedBytes
andPyBackedStr
, andDisplay
forPyBackedStr
. #4020import_exception_bound!
macro to import exception types without generating GIL Ref functionality for them. #4027Changed
#[setter]
function arguments. #3998#[inline]
hints on manyBound
andBorrowed
methods. #4024Fixed
#[pyo3(from_py_with = "")]
in#[setter]
methods #3995&Bound
in#[setter]
methods. #3998#[pymodule]
,#[pyfunction]
and#[pyclass]
macros. #4009pyo3::import_exception!
does not exist. #4012#[pymethod]
with a receiver and additional arguments. #4015v0.21.0
Compare Source
Added
PyMemoryView
type. #3514async fn
in for#[pyfunction]
and#[pymethods]
, with theexperimental-async
feature. #3540 #3588 #3599 #3931PyTypeInfo
forPyEllipsis
,PyNone
andPyNotImplemented
. #3577#[pyclass]
on enums that have non-unit variants. #3582chrono
feature withabi3
feature. #3664FromPyObject
,IntoPy<PyObject>
andToPyObject
are implemented onstd::duration::Duration
#3670PyString::to_cow
. AddPy<PyString>::to_str
,Py<PyString>::to_cow
, andPy<PyString>::to_string_lossy
, as ways to access Python string data safely beyond the GIL lifetime. #3677Bound<T>
andBorrowed<T>
smart pointers as a new API for accessing Python objects. #3686PyNativeType::as_borrowed
to convert "GIL refs" to the newBound
smart pointer. #3692FromPyObject::extract_bound
method, to migrateFromPyObject
implementations to the Bound API. #3706gil-refs
feature to allow continued use of the deprecated GIL Refs APIs. #3707PyAnyMethods
for binary operators (add
,sub
, etc.) #3712chrono-tz
feature allowing conversion betweenchrono_tz::Tz
andzoneinfo.ZoneInfo
#3730PyType_GetModuleByDef
. #3734std::time::SystemTime
anddatetime.datetime
#3736Py::as_any
andPy::into_any
. #3785PyStringMethods::encode_utf8
. #3801PyBackedStr
andPyBackedBytes
, as alternatives to&str
and&bytes
where a Python object owns the data. #3802 #3991#[pymodule]
macro on Rustmod
blocks, with theexperimental-declarative-modules
feature. #3815ExactSizeIterator
forset
andfrozenset
iterators onabi3
feature. #3849Py::drop_ref
to explicitly drop a `Py`` and immediately decrease the Python reference count if the GIL is already held. #3871#[pymodule]
macro on single argument functions that take&Bound<'_, PyModule>
. #3905FromPyObject
forCow<str>
. #3928Default
forGILOnceCell
. #3971PyDictMethods::into_mapping
,PyListMethods::into_sequence
andPyTupleMethods::into_sequence
. #3982Changed
PyDict::from_sequence
now takes a single argument of type&PyAny
(previously took two argumentsPython
andPyObject
). #3532Py::is_ellipsis
andPyAny::is_ellipsis
in favour ofany.is(py.Ellipsis())
. #3577PyTypeInfo
functionality into new traitsHasPyGilRef
andPyTypeCheck
. #3600PyTryFrom
andPyTryInto
traits in favor ofany.downcast()
via thePyTypeCheck
andPyTypeInfo
traits. #3601&self
/&mut self
#3609FromPyObject
for set types now also acceptfrozenset
objects as input. #3632FromPyObject
forbool
now also accepts NumPy'sbool_
as input. #3638AsRefSource
associated type toPyNativeType
. #3653.is_true
to.is_truthy
onPyAny
andPy<PyAny>
to clarify that the test is not based on identity with or equality to the True singleton. #3657PyType::name
is nowPyType::qualname
whereasPyType::name
efficiently accesses the full name which includes the module name. #3660Iter(A)NextOutput
types are now deprecated and__(a)next__
can directly return anything which can be converted into Python objects, i.e. awaitables do not need to be wrapped intoIterANextOutput
orOption
any more.Option
can still be used as well and returningNone
will trigger the fast path for__next__
, stopping iteration without having to raise aStopIteration
exception. #3661FromPyObject
onchrono::DateTime<Tz>
for allTz
, not justFixedOffset
andUtc
. #3663PyTzInfoAccess
trait. For the deprecated gil-ref API, the trait is now implemented for&'py PyTime
and&'py PyDateTime
instead ofPyTime
andPyDate
. #3679__traverse__
become no-ops for unsendable pyclasses if on the wrong thread, thereby avoiding hard aborts at the cost of potential leakage. #3689PyNativeType
inpyo3::prelude
. #3692extract::<i64>
(and other integer types) by avoiding call to__index__()
converting the value to an integer for 3.10+. Gives performance improvement of around 30% for successful extraction. #3742FromPyObject
forPy<T>
to justT: PyTypeCheck
. #3776PySet
andPyFrozenSet
iterators now always iterate the equivalent ofiter(set)
. (A "fast path" with no noticeable performance benefit was removed.) #3849FromPyObject
for&str
,Cow<str>
,&[u8]
andCow<[u8]>
onto a temporary traitFromPyObjectBound
whengil-refs
feature is deactivated. #3928GILPool
,Python::with_pool
, andPython::new_pool
. #3947Removed
Fixed
Py_MAX_NDIMS
in favour ofPyBUF_MAX_NDIM
. #3757datetime
types when an invaliddatetime
module is on sys.path. #3818non_local_definitions
lint warning triggered by many PyO3 macros. #3901PyCode
andPyCode_Type
on PyPy:PyCode_Type
is not exposed by PyPy. #3934Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.