[pypy-svn] r35841 - in pypy/dist/pypy: interpreter objspace/std

cfbolz at codespeak.net cfbolz at codespeak.net
Sun Dec 17 18:50:57 CET 2006


Author: cfbolz
Date: Sun Dec 17 18:50:15 2006
New Revision: 35841

Modified:
   pypy/dist/pypy/interpreter/typedef.py
   pypy/dist/pypy/objspace/std/dictmultiobject.py
Log:
use the sharing dict only for instances


Modified: pypy/dist/pypy/interpreter/typedef.py
==============================================================================
--- pypy/dist/pypy/interpreter/typedef.py	(original)
+++ pypy/dist/pypy/interpreter/typedef.py	Sun Dec 17 18:50:15 2006
@@ -183,7 +183,10 @@
             def user_setup(self, space, w_subtype):
                 self.space = space
                 self.w__class__ = w_subtype
-                self.w__dict__ = space.newdict()
+                if space.config.objspace.std.withsharingdict:
+                    from pypy.objspace.std import dictmultiobject
+                    self.w__dict__ = dictmultiobject.W_DictMultiObject(space,
+                            sharing=True)
                 self.user_setup_slots(w_subtype.nslots)
     else:
         supercls = cls

Modified: pypy/dist/pypy/objspace/std/dictmultiobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictmultiobject.py	(original)
+++ pypy/dist/pypy/objspace/std/dictmultiobject.py	Sun Dec 17 18:50:15 2006
@@ -598,7 +598,7 @@
         self._dict_infos.append(self)
     def __repr__(self):
         args = []
-        for k in sorted(self.__dict__):
+        for k in py.builtin.sorted(self.__dict__):
             v = self.__dict__[k]
             if v != 0:
                 args.append('%s=%r'%(k, v))
@@ -721,10 +721,10 @@
 class W_DictMultiObject(W_Object):
     from pypy.objspace.std.dicttype import dict_typedef as typedef
 
-    def __init__(w_self, space):
+    def __init__(w_self, space, sharing=False):
         if space.config.objspace.std.withdictmeasurement:
             w_self.implementation = MeasuringDictImplementation(space)
-        elif space.config.objspace.std.withsharingdict:
+        elif space.config.objspace.std.withsharingdict and sharing:
             w_self.implementation = SharedDictImplementation(space)
         else:
             w_self.implementation = space.emptydictimpl



More information about the Pypy-commit mailing list