Description
The main steps remaining to remove GIL Refs:
For 0.22
In 0.22 the gil-refs
feature will continue to be available, but with two major differences from 0.21. The deprecation warnings will be unconditional and the APIs will be gated behind the feature.
-
Upgrade all of the deprecated APIs to be gated behind the
gil-refs
feature:#[cfg_attr( not(feature = "gil-refs"), deprecated( since = "0.21.0", note = "use `Py::from_owned_ptr(py, ptr)` or `Bound::from_owned_ptr(py, ptr)` instead" ) )]
To
#[cfg(feature = "gil-refs")] #[deprecated( since = "0.21.0", note = "use `Py::from_owned_ptr(py, ptr)` or `Bound::from_owned_ptr(py, ptr)` instead" )]
-
buffer.rs
feature gate deprecated APIs forPyBuffer
#4144 -
conversion.rs
feature gate deprecated APIs forPython
#4173 -
conversions/num_complex.rs
feature gate deprecated APIs forPyFloat
andPyComplex
#4145 -
err/mod.rs
feature gate deprecated APIs forPyErr
and exceptions #4136 -
exceptions.rs
feature gate deprecated APIs forPyErr
and exceptions #4136 -
gil.rs
feature gate deprecated APIs forGILPool
#4181 -
impl_/deprecations.rs
feature gate APIs usinginto_gil_ref
(Part 2) #4166 -
instance.rs
feature gate deprecated APIs forPy
#4142 -
marker.rs
feature gate APIs usinginto_gil_ref
(Part 1) #4160 feature gate APIs usinginto_gil_ref
(Part 2) #4166 feature gate deprecated more APIs forPy
#4169 feature gateas/into_gil_ref
APIs (Part 3) #4172 feature gate deprecated APIs forPython
#4173 -
marshal.rs
feature gate deprecated APIs formarshal
#4149 -
pycell.rs
split more impl blocks (preparation ofPyCell
feature gate) #4175 feature gatePyCell
#4177 -
type_object.rs
feature gate deprecated APIs forPyType
,PyTypeInfo
andPySuper
#4134 -
types/any.rs
(Tests) portPyAny
tests toBound
API #4140 -
types/boolobject.rs
feature gate deprecated APIs forPyBool
#4159 -
types/bytearray.rs
feature gate deprecated APIs forPyBytes
andPyPyByteArray
#4131 -
types/bytes.rs
feature gate deprecated APIs forPyBytes
andPyPyByteArray
#4131 -
types/capsule.rs
feature gate deprecated APIs forPyCapsule
#4112 -
types/complex.rs
feature gate deprecated APIs forPyFloat
andPyComplex
#4145 -
types/datetime.rs
feature gate deprecated APIs fordatetime
types #4111 -
types/dict.rs
feature gate deprecated APIs forPyDict
#4108 -
types/ellipsis.rs
feature gate deprecated APIs forPyEllipsis
,PyNone
andPyNotImplemented
#4132 -
types/float.rs
feature gate deprecated APIs forPyFloat
andPyComplex
#4145 -
types/frozenset.rs
feature gate deprecated APIs forPyFrozenSet
#4118 -
types/function.rs
feature gate deprecated APIs forPyCFunction
#4154 -
types/iterators.rs
feature gate deprecated APIs forPyIterator
#4119 -
types/list.rs
feature gate deprecated APIs forPyList
#4127 -
types/memoryview.rs
feature gate deprecated APIs forPyMemoryView
#4152 -
types/module.rs
feature gate deprecated APIs forPyModule
#4151 -
types/none.rs
feature gate deprecated APIs forPyEllipsis
,PyNone
andPyNotImplemented
#4132 -
types/notimplemented.rs
feature gate deprecated APIs forPyEllipsis
,PyNone
andPyNotImplemented
#4132 -
types/pysuper.rs
feature gate deprecated APIs forPyType
,PyTypeInfo
andPySuper
#4134 -
types/sequence.rs
(Tests) portPySequence
tests toBound
API #4139 -
types/set.rs
feature gate deprecated APIs forPySet
#4096 -
types/slice.rs
feature gate deprecated APIs forPySlice
#4141 -
types/string.rs
feature gate deprecated APIs forPyString
#4101 -
types/tuple.rs
feature gate deprecated APIs forPyTuple
#4107 -
types/typeobject.rs
feature gate deprecated APIs forPyType
,PyTypeInfo
andPySuper
#4134
-
-
Remove default implementation of
FromPyObject::extract_bound
(to force users to implement it). feature gateas/into_gil_ref
APIs (Part 3) #4172 -
To get 0.21 out the door I left several test suites with
#[allow(deprecated)]
or#[cfg_attr(not(feature = "gil-refs"), allow(deprecated)]
. We'll need to update these. I like to keep coverage high but I think for sake of practicality I'm ok if we migrate all the tests to the bound API and trust the GIL Refs API is correct by virtue of being implemented on top of the Bound API. -
Update documentation on
Python
type
For 0.23
- Mass deletion of deprecated APIs🚀
- For
_bound
variants likePyTuple::new_bound
:- Add plain variants like
PyTuple::new
again. - Add deprecation markers on
PyTuple::new_bound
to nudge users to the plain versions again.
- Add plain variants like
Optional polishing tasks from #3684
- Split
PyModuleMethods
to move functionality related to creating / building new modules into aPyModuleBuilder
? implementPyModuleMethods
#3703 (comment) - Generic
IntoPy<Py<T>> for Bound<'_, T>
? implementPyTupleMethods
#3681 (comment) - Should
Borrowed<'py, 'py, T>::into_gil_ref
become public API as well? -
FromPyObject
could gain a lifetime'a
to its argument&'a Bound<'py>
, allowing:- downcasting the
Bound
to allowimpl FromPyObject for &Bound
impl FromPyObject<'a, '_> for &'a str
without the pool; as the lifetime of the string borrow depends on the lifetime of the input, not the GIL lifetime- would allow
PyRef
andPyRefMut
to store&'a Bound<'py, T>
(or borrowed) and avoid reference count overhead
- downcasting the
- Update
py.None()
,py.Ellipsis()
andpy.NotImplemented()
to returnBorrowed<'py, 'py, PyNone>
(etc.) - It would be nice to accept
#[pyo3(from_py_with = "PyAnyMethods::len")]
(and similar)