-
Notifications
You must be signed in to change notification settings - Fork 778
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 Py::get for GIL-independent access to frozen classes. #3158
Conversation
0d5e834
to
63acd0c
Compare
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.
Thanks, yes this is what I was thinking!
Trying to write an example, I noticed that making
PyCell::get_frozen
public is most likely not useful as there is no way to get safely get a&PyCell
without acquiring the GIL first?
Good point. It may still be nice to have this method for symmetry with Py
? Also, it might be more performant (it can avoid the .borrow()
/ .try_borrow()
/ PyRef
dance entirely, though that is probably optimised out anyway for frozen classes).
As for name... I'd quite like to have this just be something concise like .get()
or .as_ref()
, though maybe those names make more sense when frozen
is the default, and it's good to have frozen
in the name for now?
I was also thinking that the thread and borrow checking would be optimized out, but then again it does not hurt to give the compiler less work to do. Will add it.
I think
Indeed, if we want to push the whole ecosystem towards this as a new default, we should probably talk about it in the docs. Its not my favourite part but I'll give it a try.
I think we should keep |
Ok, so I gave the guide part a try. Please have another look when convenient. |
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.
👍 thanks - overall looking great, just some small suggestions to wording. Needs tests!
EDIT: I see the examples function as tests, it's unfortunate they don't contribute to coverage yet. |
Yes, this is also a big issue for rust-numpy but I don't think there is anything we can do until taiki-e/cargo-llvm-cov#2 is resolved. I will add some UI tests nevertheless as the duplication should be harmless. Especially tests that this cannot be used on unfrozen classes should be useful. |
Coverage appears reasonable now. |
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.
Perfect, thanks!
bors r+
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
@davidhewitt Is this what you had in mind for #3154?
The name is an obvious candidate for bikeshedding.
Trying to write an example, I noticed that making
PyCell::get_frozen
public is most likely not useful as there is no way to safely get a&PyCell
without acquiring the GIL first?