convert &'py PyList -> PyList<'py> #3253
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a branch to continue the conversation from #3205 (comment)
It adds an (internal for now)
PyAnyOwned<'py>
, which could eventually becomePyAny<'py>
, and attempts to gauge fallout by replacing&'py PyList
withPyList<'py>
implemented on top ofPyAnyOwned<'py>
.Because of the scale of the churn, I think it's more realistic to implement migration of each type in individual PRs. I think a single branch and PR to rebuild the entirety of PyO3 would be unreviewable. Probably
&PyAny
needs to be migrated first, although I want us to understand what changes look like for the core collection types (list, dict, tuple) before we commit to this road for definite.Doesn't compile yet because a lot of the conversion traits aren't implemented properly for
PyList<'py>
. I might try to refine further later if we think this is worth pursuing.Already we see the following migration efforts:
from_owned_ptr
methods etc.PyList<'py>
has interesting consequences foris_instance
and similar generic methods.x.is_instance_of::<PyList<'_>>()
x.downcast::<PyList<'_>>()
Of these, I think only the fourth bullet needs further consideration. If users don't have the
elided_lifetimes_in_paths
lint enabled, then I believe they can continue writingx.is_instance_of<PyList>()
without the lifetime. However, the papercut is still notable. I think this would just have to be noted as part of syntactical drawbacks which we could describe as things which would go away ifarbitrary_self_types
stabilised (any PyO3 migrated to it).