Conversation
4f08cdf to
d790a5a
Compare
|
Let's make a decision about #3703 (comment) before reviewing this; if we agree to slow things down I'll remove the deprecations from here. |
|
Okay, rebased. To make the deprecation in the macro output conditional I added a Also, I'm really not feeling keen on |
IIRC, all |
f4e88ff to
2344c90
Compare
CodSpeed Performance ReportMerging #3705 will degrade performances by 19.27%Comparing Summary
Benchmarks breakdown
|
|
Ok, this is finally reviewable! 🎉 |
|
I would like to review this, but it would be helpful if the conflicts were fixed first. |
|
Ahh aha as soon as I'd got it ready the new changes to |
|
Fixed! |
Icxolu
left a comment
There was a problem hiding this comment.
I added one remark, otherwise this looks good to me 🚀
src/types/typeobject.rs
Outdated
| /// This does not take ownership of the FFI pointer's "reference". The target type | ||
| /// object will have its reference count increased by 1, which will be released when | ||
| /// the `Bound` is dropped. |
There was a problem hiding this comment.
This does now take ownership, or did I misunderstand what you meant here?
There was a problem hiding this comment.
Uff, it's assuming that the reference is a borrowed pointer and creates a new reference. I agree my wording here was not the best.
Maybe it's better if we go a little bit inconsistent here and introduce this method with the new clearer name from_borrowed_type_ptr (forget the bound bit)?
That'd then match the from_borrowed methods which I think I'm about to introduce in a new PR...
There was a problem hiding this comment.
I pushed that as a new commit.
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
Co-authored-by: Lily Foote <code@lilyf.org>
|
🎉 thanks @adamreichold @Icxolu @LilyFoote - this was a thorny one and it feels like quite the milestone to finally get this one rounded out! |
src/types/typeobject.rs
Outdated
| pub unsafe fn from_borrowed_type_ptr<'py>( | ||
| py: Python<'py>, | ||
| p: *mut ffi::PyTypeObject, | ||
| ) -> Bound<'py, PyType> { |
There was a problem hiding this comment.
| pub unsafe fn from_borrowed_type_ptr<'py>( | |
| py: Python<'py>, | |
| p: *mut ffi::PyTypeObject, | |
| ) -> Bound<'py, PyType> { | |
| pub unsafe fn from_borrowed_type_ptr( | |
| py: Python<'_>, | |
| p: *mut ffi::PyTypeObject, | |
| ) -> Bound<'_, PyType> { |
Split from #3606
This PR implements the
PyTypeMethodstrait and the bound variants of the constructors forPyType.The most interesting thing in this PR is the bound variant of
PyType::from_type_ptr, which I decided to introduce asPyType::from_type_ptr_borrowed, because that pointer doesn't carry ownership.There's possibly arguments that one (or both) of the
PyTypeconstructors should not have bound variants introduced and we should rework the APIs, e.g.:PyType::newin favour ofT::type_object(orPython::get_type)PyType::from_type_ptr_borrowedless likestd::slice::from_raw_parts, e.g. should it force a reference count increase?