-
Notifications
You must be signed in to change notification settings - Fork 763
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
Remove ToPyPointer and so on from pyclass #335
Conversation
6e5353b
to
7d7e55d
Compare
Thank you, the two types are great! Both structs should get a docstring with an example, a note in the guide and a conversion from PyObject to that struct, so that it can be used in arguments. For |
You mean
Thanks, I'll try this. |
48957e0
to
76e30b5
Compare
90c169c
to
22687c3
Compare
Just completed fixing tests, please wait a little for documents. |
Ready to be reviewed 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.
Added some minor stuff, otherwise it's looking good!
Three more things that have no line they belong to:
- The guide should say something about those types. Mainly explain that those two are meant to ensure that an instance of a rust struct is actually part of an python object and that you need ot use
Py<T>
to store an object for longer than the GIL lifetime - Are there
T
s for PyRef that do not implementPyTypeInfo
? - PyRef should be neither Send not Sync (e.g. adding a
PhantomData<Rc<()>>
field achieves that; Negative impls seem to be still unstable)
Thanks for your review!
I think there aren't so added a bound to PyRef itself. |
Write a draft of document, and removed |
guide/src/class.md
Outdated
@@ -16,6 +16,68 @@ struct MyClass { | |||
|
|||
The above example generates implementations for `PyTypeInfo` and `PyTypeObject` for `MyClass`. | |||
|
|||
## Get Python objects from `pyclass` | |||
In rust side, we can get a Python object which includes `pyclass` by 3 methods. |
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.
This needs a short explanation that if you instantiate a rust struct, it doesn't need to be part of a python object a python object. PyRef however guarantees that the struct instance is part of a python object and that you're also holding the GIL, which allows you to modify the struct.
Everything else looks good!
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.
👍
I'll rebase #344 onto this once it is merged to master, it shouldn't be much more than a bit of search an replace. |
And introduce
PyRef
andPyRefMut
.See #320 for the reason.
Currently I don't have good idea for
PyIterProtocol
test and it still fails to be compiled.Fixes #308