[Martin von Löwis] > A mutable type is one whose instances have state that can change over > the life of the object. [...] Interesting presentation. The following detail is worth stressing: > equal objects should hash equal. This should be stressed as a formal requirement for a correctly behaved hashing function. The other formal requirement being that a hash function should always compute the same value for the lifespan of an object, and that value should be a non-negative integer (not a long one?). A _desirable_ property, but not a requirement, is that two unequal objects yield different hashes. So, instead of explaining how we should cleverly use `__hash__' to describe immutability, we might describe what `__hash__' ought to be, and then merely notice that hashable objects could be useful to represent immutable objects (whether user objects or builtin objects). -- François Pinard http://www.iro.umontreal.ca/~pinard
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4