-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Implement PartialEq
for Param
in rust using PyO3
#12697
Conversation
- Implement `PartialEq` using `Python::with_gil()` to compare parameters through Python. - Add display method for debugging.
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 9747009629Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
It's possibly better to use specific methods for these that take a |
Would there be a better way of performing this comparison that could skip the passing of a I understand that with the way things are built now, the circuit is the one taking ownership of the parameters of each instruction, but I don't know how I would translate this well enough. |
No, because fundamentally we must have a You can define a custom |
PartialEq
and Display
for Param
in rust using PyO3PartialEq
for Param
in rust using PyO3
After some consideration, @jakelishman, I decided to just use the I also decided that the |
Using Python's As long as there are Python objects here, I really can't see a way through without explicitly requiring the GIL token, or converting one of the objects into some sort of "bound" version, which includes a Python GIL lifetime within it in order to use that in the equality. But you don't have to use the |
Pull Request Test Coverage Report for Build 9779973622Details
💛 - Coveralls |
Sounds good, I'll reevaluate the way I've implemented things. Thank you for your feedback |
Summary
After #12459 merged, a limited infrastructure for
Param
in Rust was introduced. The following commits aim to extend its functionality a little to allow for comparison and further debugging which will be of great use for #12292 and #12585.Details and comments
PartialEq
usingPython::with_gil()
to compare parameters through Python.- AddNot necessaryDisplay
method for debugging using the Python__repr__
magic method.