remove AsPyPointer from FromPyObject impl for Py<T>`#3406
Closed
davidhewitt wants to merge 1 commit intoPyO3:mainfrom
Closed
remove AsPyPointer from FromPyObject impl for Py<T>`#3406davidhewitt wants to merge 1 commit intoPyO3:mainfrom
FromPyObject impl for Py<T>`#3406davidhewitt wants to merge 1 commit intoPyO3:mainfrom
Conversation
alex
approved these changes
Aug 19, 2023
Member
Author
|
I can't decide whether this one is CHANGELOG worthy. By removing bounds here I can't imagine it would affect user code? |
| ob.extract::<&T::AsRefTarget>() | ||
| .map(|val| Py::from_borrowed_ptr(ob.py(), val.as_ptr())) | ||
| if ob.is_instance_of::<T>() { | ||
| Ok(unsafe { Py::from_non_null(NonNull::new_unchecked(ob.into_ptr())) }) |
Member
There was a problem hiding this comment.
So this can assume that val will always point to the same object (i.e. not a sub-allocation) as ob?
Member
Author
There was a problem hiding this comment.
Ah, that's a good observation. I think I've always assumed that should be the case, and I'd quite like this to be true. But it is breaking. So if we like this property we could document this as a breaking change?
Member
Author
|
Closing as I think we'll release 0.20 without this change and then hopefully a rework in 0.21 will remove the need for this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related to #3358
This drops the
AsPyPointerbound from thePy<T>conversion. I think the resulting implementation is more intuitive and almost certainly more performant.