[pypy-svn] rev 807 - pypy/trunk/src/pypy/objspace/std

mwh at codespeak.net mwh at codespeak.net
Fri Jun 13 16:12:56 CEST 2003


Author: mwh
Date: Fri Jun 13 16:12:56 2003
New Revision: 807

Modified:
   pypy/trunk/src/pypy/objspace/std/objspace.py
Log:
add a version of StdObjSpace.is_ that speeds up running dis-pregoal.py
by 40% or so :-)


Modified: pypy/trunk/src/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/objspace.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/objspace.py	Fri Jun 13 16:12:56 2003
@@ -257,6 +257,17 @@
 
     getdict = MultiMethod('getdict', 1, [])  # get '.__dict__' attribute
 
+    def is_(self, w_one, w_two):
+        # XXX this is a hopefully temporary speed hack:
+        from cpythonobject import W_CPythonObject
+        if isinstance(w_one, W_CPythonObject):
+            if isinstance(w_two, W_CPythonObject):
+                return self.newbool(w_one.cpyobj is w_two.cpyobj)
+            else:
+                return self.newbool(0)
+        else:
+            return self.newbool(w_one is w_two)
+
 
 # add all regular multimethods to StdObjSpace
 for _name, _symbol, _arity, _specialnames in ObjSpace.MethodTable:


More information about the Pypy-commit mailing list