[Python-Dev] RE: [Python-checkins] python/dist/src/Lib weakref.py,1.19,1.20 (original) (raw)
Raymond Hettinger python@rcn.com
Sun, 25 May 2003 02:35:17 -0400
- Previous message: [Python-Dev] RE: [Python-checkins] python/dist/src/Lib weakref.py,1.19,1.20
- Next message: [Python-Dev] RE: [Python-checkins] python/dist/src/Lib weakref.py,1.19,1.20
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 "", 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
- Previous message: [Python-Dev] RE: [Python-checkins] python/dist/src/Lib weakref.py,1.19,1.20
- Next message: [Python-Dev] RE: [Python-checkins] python/dist/src/Lib weakref.py,1.19,1.20
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]