[pypy-svn] r73178 - in pypy/branch/reduce-instance-size-experiments/pypy/objspace/std: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Mar 30 17:42:17 CEST 2010


Author: cfbolz
Date: Tue Mar 30 17:42:15 2010
New Revision: 73178

Modified:
   pypy/branch/reduce-instance-size-experiments/pypy/objspace/std/inlinedict.py
   pypy/branch/reduce-instance-size-experiments/pypy/objspace/std/test/test_inlinedict.py
Log:
some simplifications


Modified: pypy/branch/reduce-instance-size-experiments/pypy/objspace/std/inlinedict.py
==============================================================================
--- pypy/branch/reduce-instance-size-experiments/pypy/objspace/std/inlinedict.py	(original)
+++ pypy/branch/reduce-instance-size-experiments/pypy/objspace/std/inlinedict.py	Tue Mar 30 17:42:15 2010
@@ -8,8 +8,7 @@
 
 def make_mixin(config):
     assert config.objspace.std.withsharingdict
-    from pypy.objspace.std.sharingdict import SharedDictImplementation
-    return make_inlinedict_mixin(SharedDictImplementation, "structure")
+    return make_inlinedict_mixin()
 
 def make_indirection_method(methname, numargs):
     # *args don't work, the call normalization gets confused
@@ -24,7 +23,9 @@
     func.func_defaults = getattr(W_DictMultiObject, methname).func_defaults
     return func
 
-def make_inlinedict_mixin(dictimplclass, attrname):
+def make_inlinedict_mixin():
+    from pypy.objspace.std.sharingdict import SharedDictImplementation
+    dictimplclass = SharedDictImplementation
     assert dictimplclass.__base__ is W_DictMultiObject
     class IndirectionIterImplementation(IteratorImplementation):
         def __init__(self, space, dictimpl, itemlist):
@@ -47,8 +48,6 @@
                 items.append((w_key, w_value))
             return IndirectionIterImplementation(self.space, self, items)
 
-    IndirectionDictImplementation.__name__ = "IndirectionDictImplementation" + dictimplclass.__name__
-
     for methname, numargs in implementation_methods:
         implname = "impl_" + methname
         if implname != "impl_iter":
@@ -69,7 +68,7 @@
             self.w__class__ = w_subtype
             self.w__dict__ = None
             init_dictattributes(self, space)
-            assert getattr(self, attrname) is not None
+            assert self.structure is not None
             self.user_setup_slots(w_subtype.nslots)
 
         def getdict(self):
@@ -81,7 +80,7 @@
             return w__dict__
 
         def _inlined_dict_valid(self):
-            return getattr(self, attrname) is not None
+            return self.structure is not None
 
         def getdictvalue(self, space, attr):
             if self._inlined_dict_valid():

Modified: pypy/branch/reduce-instance-size-experiments/pypy/objspace/std/test/test_inlinedict.py
==============================================================================
--- pypy/branch/reduce-instance-size-experiments/pypy/objspace/std/test/test_inlinedict.py	(original)
+++ pypy/branch/reduce-instance-size-experiments/pypy/objspace/std/test/test_inlinedict.py	Tue Mar 30 17:42:15 2010
@@ -10,7 +10,7 @@
     nslots = 0
 
 class TestMixin(object):
-    Mixin = make_inlinedict_mixin(StrDictImplementation, "content")
+    Mixin = make_inlinedict_mixin()
     class FakeObject(Mixin):
         def user_setup_slots(self, nslots):
             pass
@@ -114,14 +114,8 @@
         assert obj.getdictvalue(self.fakespace, "hello") is None
 
 
-class TestMixinShared(TestMixin):
-    Mixin = make_inlinedict_mixin(SharedDictImplementation, "structure")
-    class FakeObject(Mixin):
-        def user_setup_slots(self, nslots):
-            pass
-
-class TestIndirectDict(BaseTestRDictImplementation):
-    Mixin = make_inlinedict_mixin(StrDictImplementation, "content")
+class TestIndirectDictShared(BaseTestRDictImplementation):
+    Mixin = make_inlinedict_mixin()
     class FakeObject(Mixin):
         def user_setup_slots(self, nslots):
             pass
@@ -132,13 +126,6 @@
         return obj.getdict()
 
 
-class TestIndirectDictShared(TestIndirectDict):
-    Mixin = make_inlinedict_mixin(SharedDictImplementation, "structure")
-    class FakeObject(Mixin):
-        def user_setup_slots(self, nslots):
-            pass
-
-
 
 
 class TestInlineDict(object):



More information about the Pypy-commit mailing list