The ‘hash’ method can be removed

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 ‘eqbut nothash’, 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

Proxy Information
Original URL
gemini://dcreager.net/languages/python/hash-method-removed.gmi
Status Code
Success (20)
Meta
text/gemini;lang=en
Capsule Response Time
409.664361 milliseconds
Gemini-to-HTML Time
0.358411 milliseconds

This content has been proxied by September (3851b).