[pypy-svn] r22835 - pypy/dist/pypy/jit

arigo at codespeak.net arigo at codespeak.net
Sun Jan 29 13:53:59 CET 2006


Author: arigo
Date: Sun Jan 29 13:53:57 2006
New Revision: 22835

Modified:
   pypy/dist/pypy/jit/hintcontainer.py
Log:
oups oups, stupid bug that took me ages to figure out.


Modified: pypy/dist/pypy/jit/hintcontainer.py
==============================================================================
--- pypy/dist/pypy/jit/hintcontainer.py	(original)
+++ pypy/dist/pypy/jit/hintcontainer.py	Sun Jan 29 13:53:57 2006
@@ -1,4 +1,4 @@
-import weakref
+import weakref, itertools
 from pypy.annotation.listdef import ListItem
 from pypy.annotation import model as annmodel
 from pypy.jit import hintmodel
@@ -6,20 +6,17 @@
 
 
 class AbstractContainerDef(object):
-    __counter = 0
+    __counter = itertools.count()
     __cache   = {}
 
     def __init__(self, bookkeeper, TYPE):
         self.T = TYPE
         self.bookkeeper = bookkeeper
         # hack to try to produce a repr that shows identifications
-        try:
-            weakdict = AbstractContainerDef.__cache[TYPE]
-        except KeyError:
-            weakdict = weakref.WeakValueDictionary()
-            AbstractContainerDef.__cache[self.__class__, TYPE] = weakdict
-        weakdict[AbstractContainerDef.__counter] = self
-        AbstractContainerDef.__counter += 1
+        key = (self.__class__, TYPE)
+        weakdict = AbstractContainerDef.__cache.setdefault(key,
+            weakref.WeakValueDictionary())
+        weakdict[AbstractContainerDef.__counter.next()] = self
 
     def __repr__(self):
         items = AbstractContainerDef.__cache[self.__class__, self.T].items()



More information about the Pypy-commit mailing list