[pypy-svn] r12241 - pypy/dist/pypy/objspace/flow
tismer at codespeak.net
tismer at codespeak.net
Fri May 13 18:39:33 CEST 2005
Author: tismer
Date: Fri May 13 18:39:33 2005
New Revision: 12241
Modified:
pypy/dist/pypy/objspace/flow/model.py
Log:
saved another 25 MB of memory by dropping Variable.instances
Modified: pypy/dist/pypy/objspace/flow/model.py
==============================================================================
--- pypy/dist/pypy/objspace/flow/model.py (original)
+++ pypy/dist/pypy/objspace/flow/model.py Fri May 13 18:39:33 2005
@@ -15,6 +15,9 @@
Var/Const/SpaceOp 205 MB 325 MB
+ Link 189 MB 311 MB
+ Block 185 MB 304 MB
+
+ Dropping Variable.instances brought
+ annotation down to 160 MB.
"""
__metaclass__ = type
@@ -165,17 +168,26 @@
class Variable:
__slots__ = ["renamed", "name", "concretetype"]
- counter = 0
- instances = {}
+ countall = 0
+ countmax = 0
+ countcurr = 0
+ instancenames = {}
+ # change this to a weakvalue dict if you want
+ # to track all alive instances
def __init__(self, name=None):
- self.name = 'v%d' % Variable.counter
+ self.name = 'v%d' % Variable.countall
self.renamed = False
- Variable.instances[self.name] = self
- Variable.counter += 1
+ Variable.instancenames[self.name] = True
+ Variable.countall += 1
+ Variable.countcurr += 1
+ Variable.countmax = max(Variable.countmax, Variable.countcurr)
if name is not None:
self.rename(name)
+ def __del__(self):
+ Variable.countcurr -= 1
+
def __repr__(self):
return '%s' % self.name
@@ -192,10 +204,10 @@
return
if '0' <= name[0] <= '9':
name = '_' + name
- del Variable.instances[self.name]
+ del Variable.instancenames[self.name]
self.renamed = True
self.name = name + '_' + self.name[1:]
- Variable.instances[self.name] = self
+ Variable.instancenames[self.name] = True
class Constant:
More information about the Pypy-commit
mailing list