-
Notifications
You must be signed in to change notification settings - Fork 64
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
Message hashes don't change with contents #73
Comments
Neither the generated message class nor its base class override the
|
Oh yes, no argument there. This argument is that they should, so that message objects may be added to a |
I don't think we should change the default semantic of the Python hash function for objects. |
We already do it as a one-off for Lines 127 to 131 in e176e70
The proposal here is simply to extend that behaviour to all messages. Quoting the documentation:
Given this, the default implementation based on identity seems bizarre. Further down:
So that seems conclusive that Msg objects probably shouldn't be hashable, since they all have mutable fields (including |
The Considering that the fields are still mutable I agree that having a hash for those might potentially be "risky". |
Eg:
The default
hash
method supplied withobject
is based on identity rather than fields, hence the above behaviour.Instead, generated messages should supply a
__hash__
function which hashes the data, possibly as simple as just passing the message's string representation tohash
.The text was updated successfully, but these errors were encountered: