If a class implements both ‘eq’ and ‘hash’, it's important for those implementations to be consistent with each other:
a == b ⇔ hash(a) == hash(b)
TIL that Python will try to help you adhere to this constraint in the presence of subclasses. If you define a subclass, and implement ‘eq’ but not ‘hash’, then Python will implicitly set ‘hash’ to ‘None’ in that class. That way you can't accidentally override the meaning of “equals” in a way that breaks hashability.
=> ‘object.hash’ documentation
This has some ramifications with the type system:
=> ‘hash’, ‘eq’, and LSP [Python Discourse]
=> » Languages » Python This content has been proxied by September (3851b).Proxy Information
text/gemini;lang=en