-
Notifications
You must be signed in to change notification settings - Fork 770
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
add Bound API constructors from borrowed pointers #3858
Conversation
CodSpeed Performance ReportMerging #3858 will degrade performances by 20.41%Comparing Summary
Benchmarks breakdown
|
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.
It seems reasonable to me, that we add both Bound
and Borrowed
variants. Found a small documentation mixup, otherwise LGTM
src/instance.rs
Outdated
@@ -480,33 +516,52 @@ impl<'py, T> Borrowed<'_, 'py, T> { | |||
} | |||
|
|||
impl<'a, 'py> Borrowed<'a, 'py, PyAny> { | |||
/// Constructs a new `Borrowed<'py, PyAny>` from a pointer. Panics if `ptr` is null. |
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.
/// Constructs a new `Borrowed<'py, PyAny>` from a pointer. Panics if `ptr` is null. | |
/// Constructs a new `Borrowed<'a, 'py, PyAny>` from a pointer. Returns an `Err` by calling `PyErr::fetch` | |
/// if `ptr` is null. |
Missing lifetime here, same for the others. Also you mixed the or_err
and panicking variants
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.
Good catch. I think I got mixed up because the functions aren't in the same order as for Bound
- I'll swap them so that from_ptr
is first at the same time 👍
Thanks for the review, will try to fixup tonight 👍 |
As per #3708 (comment)
I decided to add both
Bound::from_borrowed_ptr
andBorrowed::from_ptr
sets of methods. I think theBound
methods make sense from a consistency withPy
angle and also for simplicity. TheBorrowed
methods may be useful in extreme cases for power users, and also are what I'd like to use internally in #3708