[issue24067] Weakproxy is an instance of collections.Iterator
Gareth Rees
report at bugs.python.org
Tue Apr 28 14:54:51 CEST 2015
Gareth Rees added the comment:
> I don't see any reason for proxy objects to be less hashable than ref objects.
The difference is that unlike a ref object, a proxy object is supposed to forward its method calls to the proxied object. So consider what happens if you forward the __hash__ method to the proxied object: the hash will change when the object dies.
A proxy object could, of course, not forward the __hash__ method, instead computing its own hash. But I think this would do more harm than good: surely most attempts to store weakref.Proxy objects in sets or dictionaries are going to be mistakes -- the user should have used a WeakKeyDictionary or a WeakSet instead.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24067>
_______________________________________
More information about the Python-bugs-list
mailing list