[pypy-svn] r70720 - in pypy/branch/cli-jit/pypy: config objspace/std
antocuni at codespeak.net
antocuni at codespeak.net
Wed Jan 20 10:09:24 CET 2010
Author: antocuni
Date: Wed Jan 20 10:09:23 2010
New Revision: 70720
Modified:
pypy/branch/cli-jit/pypy/config/pypyoption.py
pypy/branch/cli-jit/pypy/objspace/std/sharingdict.py
Log:
tentative checkin: implement WeakValueDictionary in rpython, without using the
implementation in rlib.rweakref. This way it works also with ootype
Modified: pypy/branch/cli-jit/pypy/config/pypyoption.py
==============================================================================
--- pypy/branch/cli-jit/pypy/config/pypyoption.py (original)
+++ pypy/branch/cli-jit/pypy/config/pypyoption.py Wed Jan 20 10:09:23 2010
@@ -360,8 +360,7 @@
# extra optimizations with the JIT
if level == 'jit':
- if type_system != 'ootype':
- config.objspace.std.suggest(withsharingdict=True)
+ config.objspace.std.suggest(withsharingdict=True)
config.objspace.std.suggest(withcelldict=True)
config.objspace.std.suggest(withinlineddict=True)
Modified: pypy/branch/cli-jit/pypy/objspace/std/sharingdict.py
==============================================================================
--- pypy/branch/cli-jit/pypy/objspace/std/sharingdict.py (original)
+++ pypy/branch/cli-jit/pypy/objspace/std/sharingdict.py Wed Jan 20 10:09:23 2010
@@ -1,7 +1,26 @@
from pypy.objspace.std.dictmultiobject import IteratorImplementation
from pypy.objspace.std.dictmultiobject import W_DictMultiObject, _is_sane_hash
from pypy.rlib.jit import purefunction_promote, hint, we_are_jitted, unroll_safe
-from pypy.rlib.rweakref import RWeakValueDictionary
+#from pypy.rlib.rweakref import RWeakValueDictionary
+
+import weakref
+class WeakValueDictionary:
+ def __init__(self):
+ self._dict = {}
+
+ def get(self, key):
+ wref = self._dict.get(key, None)
+ if wref is None:
+ return None
+ return wref()
+
+ def set(self, key, value):
+ if value is None:
+ self._dict.pop(key, None)
+ else:
+ #assert isinstance(value, self._valueclass)
+ self._dict[key] = weakref.ref(value)
+
NUM_DIGITS = 4
@@ -17,7 +36,8 @@
self.keys = keys
self.length = length
self.back_struct = back_struct
- other_structs = RWeakValueDictionary(SharedStructure)
+ #other_structs = RWeakValueDictionary(SharedStructure)
+ other_structs = WeakValueDictionary()
self.other_structs = other_structs
self.last_key = last_key
self._size_estimate = length << NUM_DIGITS
More information about the Pypy-commit
mailing list