[pypy-svn] r8258 - in pypy/trunk/src/pypy: interpreter objspace

arigo at codespeak.net arigo at codespeak.net
Thu Jan 13 16:26:19 CET 2005


Author: arigo
Date: Thu Jan 13 16:26:19 2005
New Revision: 8258

Modified:
   pypy/trunk/src/pypy/interpreter/gateway.py
   pypy/trunk/src/pypy/objspace/descroperation.py
Log:
Got rid of performance_shortcut_call() methods of BuiltinCode.  It was found
that just special-casing Function at the proper place was enough to get the
same performance improvement.


Modified: pypy/trunk/src/pypy/interpreter/gateway.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/gateway.py	(original)
+++ pypy/trunk/src/pypy/interpreter/gateway.py	Thu Jan 13 16:26:19 2005
@@ -92,49 +92,6 @@
     def getdocstring(self):
         return self.docstring
 
-    def performance_shortcut_call(self, space, args):
-        # this shortcut is only used for performance reasons
-        args_w, kwds_w = args.unpack()
-        if self.generalargs or kwds_w:
-            return None
-        if not (self.minargs <= len(args_w) <= self.maxargs):
-            return None
-        if self.ismethod:
-            if not args_w:
-                return None
-            args_w = list(args_w)
-            args_w[0] = space.unwrap(args_w[0])
-        if self.spacearg:
-            w_result = self.func(space, *args_w)
-        else:
-            w_result = self.func(*args_w)
-        if w_result is None:
-            w_result = space.w_None
-        return w_result
-
-    def performance_shortcut_call_meth(self, space, w_obj, args):
-        # this shortcut is only used for performance reasons
-        if self.generalargs:
-            if self.ismethod and not self.spacearg and len(self.sig[0]) == 1:
-                w_result = self.func(space.unwrap(w_obj), args)
-            else:
-                return None
-        else:
-            args_w, kwds_w = args.unpack()
-            if kwds_w:
-                return None
-            if not (self.minargs <= 1+len(args_w) <= self.maxargs):
-                return None
-            if self.ismethod:
-                w_obj = space.unwrap(w_obj) # abuse name w_obj
-            if self.spacearg:
-                w_result = self.func(space, w_obj, *args_w)
-            else:
-                w_result = self.func(w_obj, *args_w)
-        if w_result is None:
-            w_result = space.w_None
-        return w_result
-
 
 class BuiltinFrame(eval.Frame):
     "Frame emulation for BuiltinCode."

Modified: pypy/trunk/src/pypy/objspace/descroperation.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/descroperation.py	(original)
+++ pypy/trunk/src/pypy/objspace/descroperation.py	Thu Jan 13 16:26:19 2005
@@ -62,14 +62,8 @@
 
     def get_and_call_args(space, w_descr, w_obj, args):
         descr = space.unwrap_builtin(w_descr)
-        # some special cases to avoid infinite recursion
+        # a special case for performance and to avoid infinite recursion
         if isinstance(descr, Function):
-            if isinstance(descr.code, BuiltinCode):
-                # this sub-special case is ONLY for performance reasons
-                w_result = descr.code.performance_shortcut_call_meth(
-                    space, w_obj, args)
-                if w_result is not None:
-                    return w_result
             return descr.call_args(args.prepend(w_obj))
         else:
             w_impl = space.get(w_descr, w_obj)
@@ -83,11 +77,9 @@
         return w_obj    # hook for hack by TrivialObjSpace
 
     def call_args(space, w_obj, args):
-        if type(w_obj) is Function and isinstance(w_obj.code, BuiltinCode):
-            # this special case is ONLY for performance reasons
-            w_result = w_obj.code.performance_shortcut_call(space, args)
-            if w_result is not None:
-                return w_result
+        # a special case for performance
+        if type(w_obj) is Function:
+            return w_obj.call_args(args)
         w_descr = space.lookup(w_obj, '__call__')
         if w_descr is None:
             raise OperationError(



More information about the Pypy-commit mailing list