[pypy-svn] r49887 - pypy/dist/pypy/objspace/std

arigo at codespeak.net arigo at codespeak.net
Tue Dec 18 14:44:32 CET 2007


Author: arigo
Date: Tue Dec 18 14:44:30 2007
New Revision: 49887

Modified:
   pypy/dist/pypy/objspace/std/dictmultiobject.py
   pypy/dist/pypy/objspace/std/objspace.py
Log:
StrDictImplement.get() is called so often that I strongly
suspect this to be a useful performance hack.  (will check)


Modified: pypy/dist/pypy/objspace/std/dictmultiobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/dictmultiobject.py	(original)
+++ pypy/dist/pypy/objspace/std/dictmultiobject.py	Tue Dec 18 14:44:30 2007
@@ -457,6 +457,10 @@
 
     def get(self, w_lookup):
         space = self.space
+        # -- This is called extremely often.  Hack for performance --
+        if type(w_lookup) is space.StringObjectCls:
+            return self.content.get(w_lookup.unwrap(space), None)
+        # -- End of performance hack --
         w_lookup_type = space.type(w_lookup)
         if space.is_w(w_lookup_type, space.w_str):
             return self.content.get(space.str_w(w_lookup), None)

Modified: pypy/dist/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/dist/pypy/objspace/std/objspace.py	(original)
+++ pypy/dist/pypy/objspace/std/objspace.py	Tue Dec 18 14:44:30 2007
@@ -190,6 +190,15 @@
         else:
             from pypy.objspace.std import dictobject
             self.DictObjectCls = dictobject.W_DictObject
+        assert self.DictObjectCls in self.model.typeorder
+
+        if not self.config.objspace.std.withrope:
+            from pypy.objspace.std import stringobject
+            self.StringObjectCls = stringobject.W_StringObject
+        else:
+            from pypy.objspace.std import ropeobject
+            self.StringObjectCls = ropeobject.W_RopeObject
+        assert self.StringObjectCls in self.model.typeorder
 
         # install all the MultiMethods into the space instance
         for name, mm in self.MM.__dict__.items():



More information about the Pypy-commit mailing list