confusing doc: mutable and hashable

Terry Reedy tjreedy at udel.edu
Sun Apr 29 06:09:46 EDT 2012


On 4/29/2012 3:57 AM, John O'Hagan wrote:

> How do function objects fit into this scheme? They have __hash__, __eq__, seem
> to work as dict keys and are mutable. Is it because their hash value doesn't
> change?

I suspect functions use the default equality and hash based on id, which 
does not change.

> Under what circumstances does an object's hash value change?

When someone has written a buggy .__hash__ method. Or perhaps if someone 
is making a non-standard, non-dict use of hash().

-- 
Terry Jan Reedy




More information about the Python-list mailing list