The old behavior for missing keys may have been a bug. Do you care about the previous behavior for deleting based on equality rather than equality *and* hash? Python 2.3b1 (#40, Apr 25 2003, 19:06:24) [MSC v.1200 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> class One: def __eq__(self, other): return other == 1 def __hash__(self): return 1492 >>> import weakref >>> wkd = weakref.WeakKeyDictionary() >>> o = One() >>> wkd[o] = None >>> len(wkd) 1 >>> del wkd[1] >>> len(wkd) 0 Python 2.3b1+ (#40, May 23 2003, 00:08:36) [MSC v.1200 32 Type "help", "copyright", "credits" or "license" for more >>> class One: ... def __eq__(self, other): ... return other == 1 ... def __hash__(self): ... return 1492 ... >>> import weakref >>> wkd = weakref.WeakKeyDictionary() >>> o = One() >>> wkd[o] = None >>> len(wkd) 1 >>> del wkd[1] Traceback (most recent call last): File "<stdin>", line 1, in ? File "C:\PY23\lib\weakref.py", line 167, in __delitem__ del self.data[ref(key)] TypeError: cannot create weak reference to 'int' object >>> len(wkd) 1 >>> Raymond Hettinger
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4