-
Notifications
You must be signed in to change notification settings - Fork 816
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 IntoPyObject
& FromPyObject
for Arc<T>
#4987
base: main
Are you sure you want to change the base?
Conversation
6d0976c
to
15b3e13
Compare
15b3e13
to
3220501
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.
Interesting workaround. I wonder whether the additional type parameters have any impact on type inference. Did you perhaps tested/noticed anything in that regard? Maybe with the derive macro?
Also: Is it sufficiently clear that a roundtrip with Arc
will not give the same Arc
? Or should we document that somewhere?
I didn't experience any weird inference behaviour when writing the existing test. The new macro tests behaves fine so I think we are good there as well.
I am not sure if it needs explicit documentation, as all roundtrip conversions create new objects, why would this one differ? That said documentation doesn't hurt nobody. |
One alternative possibility here is that we change the I imagine mostly that would be |
I do not fully understand your second case. Can you give me a example of a class definition? |
Closes #4887.
This PR adds IntoPyObject and FromPyObject for Arc by forwarding the conversion to &T. Since we can’t access T, we work around the naming of associated types by adding extra type parameters. This fixes the conversion error when using #[pyclass(get)] with Arc fields.