Message1382

Author lheuer
Recipients
Date 2007-05-11.10:06:45
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Even if the object defines a __hash__ method, the WeakValueDictionary does not work:

>>> class X(object):
       def __init__(self, id):
           self.id = id
       def __hash__(self):
           return hash(self.id)

>>> # Code taken from the CPython example:
>>> import weakref
>>> _id2obj_dict = weakref.WeakValueDictionary()
>>> def remember(obj):
       oid = id(obj)
       _id2obj_dict[oid] = obj
       return oid
>>> x = X(123)
>>> remember(x)
Traceback (innermost last):
...
TypeError: unhashable instance


History
Date User Action Args
2008-02-20 17:17:39adminlinkissue1622207 messages
2008-02-20 17:17:39admincreate