[Python-ideas] A Protocol for Making an Object Immutable

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Oct 7 07:06:25 CEST 2011


Eric Snow wrote:
> So, is being hashable necessarily
> tied to being immutable?

It's tied to immutability of those aspects involved in
equality comparison. If a type is to behave predictably
when used as a dict key, then two instances that compare
equal must always compare equal, and the converse.
Attributes that don't affect equality comparison are
free to change, however.

-- 
Greg



More information about the Python-ideas mailing list