Gareth Rees added the comment:

The documentation says that weakref.Proxy objects are not hashable because 
"this avoids a number of problems related to their fundamentally mutable 
nature, and prevent their use as dictionary keys".

Hashable objects must be immutable, otherwise the hash might change, 
invalidating the invariants that make dictionaries work, but Proxy objects are 
fundamentally mutable: when there are no more strong references to the proxied 
object, the object gets destroyed and the Proxy object now refers to None. If 
the Proxy object were hashable then its hash would change at this point.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24067>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to