[pypy-svn] r50453 - pypy/dist/pypy/annotation

cfbolz at codespeak.net cfbolz at codespeak.net
Wed Jan 9 00:46:17 CET 2008


Author: cfbolz
Date: Wed Jan  9 00:46:16 2008
New Revision: 50453

Modified:
   pypy/dist/pypy/annotation/bookkeeper.py
   pypy/dist/pypy/annotation/model.py
Log:
store the debugging info that SomeObjects keep into the bookkeeper, so that not
all of it is kept alive across test runs. Should reduce memory usage of test
runs dramatically.


Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py	(original)
+++ pypy/dist/pypy/annotation/bookkeeper.py	Wed Jan  9 00:46:16 2008
@@ -179,6 +179,9 @@
 
         self.stats = Stats(self)
 
+        # used in SomeObject.__new__ for keeping debugging info
+        self._someobject_coming_from = {}
+
         delayed_imports()
 
     def count(self, category, *args):

Modified: pypy/dist/pypy/annotation/model.py
==============================================================================
--- pypy/dist/pypy/annotation/model.py	(original)
+++ pypy/dist/pypy/annotation/model.py	Wed Jan  9 00:46:16 2008
@@ -114,7 +114,6 @@
 
     # for debugging, record where each instance comes from
     # this is disabled if DEBUG is set to False
-    _coming_from = {}
     def __new__(cls, *args, **kw):
         self = super(SomeObject, cls).__new__(cls, *args, **kw)
         if DEBUG:
@@ -124,20 +123,26 @@
             except AttributeError:
                 pass
             else:
-                SomeObject._coming_from[id(self)] = position_key, None
+                bookkeeper._someobject_coming_from[id(self)] = position_key, None
         return self
 
     def origin(self):
-        return SomeObject._coming_from.get(id(self), (None, None))[0]
-    def set_origin(self, nvalue):
-        SomeObject._coming_from[id(self)] = nvalue, self.caused_by_merge
-    origin = property(origin, set_origin)
-    del set_origin
+        bookkeeper = pypy.annotation.bookkeeper.getbookkeeper()
+        if bookkeeper is None:
+            return None
+        return bookkeeper._someobject_coming_from.get(id(self), (None, None))[0]
+    origin = property(origin)
 
     def caused_by_merge(self):
-        return SomeObject._coming_from.get(id(self), (None, None))[1]
+        bookkeeper = pypy.annotation.bookkeeper.getbookkeeper()
+        if bookkeeper is None:
+            return None
+        return bookkeeper._someobject_coming_from.get(id(self), (None, None))[1]
     def set_caused_by_merge(self, nvalue):
-        SomeObject._coming_from[id(self)] = self.origin, nvalue
+        bookkeeper = pypy.annotation.bookkeeper.getbookkeeper()
+        if bookkeeper is None:
+            return
+        bookkeeper._someobject_coming_from[id(self)] = self.origin, nvalue
     caused_by_merge = property(caused_by_merge, set_caused_by_merge)
     del set_caused_by_merge
 



More information about the Pypy-commit mailing list