[docs] [issue13707] Clarify hash() constancy period
Martin v. Löwis
report at bugs.python.org
Wed Jan 4 09:17:42 CET 2012
Martin v. Löwis <martin at v.loewis.de> added the comment:
> Martin, I do not understand. The default hash is based on id (as is
> default equality comparison), not value.
In the default implementation, the id *is* the object's value (i.e.
objects, by default, only compare equal if they are identical). So
the default implementation is just a special case of the more general
rule that hashes need to be consistent with equality.
> Are you OK with hash values changing if the 'value' changes?
An object that can change its value (i.e. a mutable object) should
fail to hash.
Python tracker <report at bugs.python.org>
More information about the docs