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
Don't serialize GridQubit hash when pickling #3791
Conversation
Are string hashes stable :) |
@mpharrigan, that is a very good question :-) I also noticed the tests were failing because we specifically do not want the hashes to depend on the particular Qid class, since, e.g. |
Looks like there are also other places where the hash of the class is used, like Moment? |
I think hash of a class is fine; we just have to avoid serializing hashes when e.g. pickling, because the hashes are not stable from one run of the python interpreter to the next. I'll change the issue title to reflect this. |
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.
awesome! Thanks for doing the fix
When hashing Qid objects we were including the
Qid
class, but class hashes are not stable between restarts of the interpreter. This caused #3777 where the hash of unpickledGridQubit
objects disagrees with otherGridQubits
to which they compare equal. Here we fix this by hashing based on the class name rather than the class object itself.Fixes #3777