[pypy-svn] r17599 - pypy/dist/pypy/objspace

arigo at codespeak.net arigo at codespeak.net
Fri Sep 16 19:57:31 CEST 2005

Author: arigo
Date: Fri Sep 16 19:57:30 2005
New Revision: 17599

Special-case calls to Methods for performance.  Based on gprof, saying that
among all calls to BuiltinFrame.setfastscope(), the most costly one is by far
the one that will end up invoking Method.descr_method_call().  This gives a
20% speed-up on the example 'random.random()'.

Modified: pypy/dist/pypy/objspace/descroperation.py
--- pypy/dist/pypy/objspace/descroperation.py	(original)
+++ pypy/dist/pypy/objspace/descroperation.py	Fri Sep 16 19:57:30 2005
@@ -1,7 +1,7 @@
 import operator
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.baseobjspace import ObjSpace, W_Root, BaseWrappable
-from pypy.interpreter.function import Function
+from pypy.interpreter.function import Function, Method
 from pypy.interpreter.gateway import BuiltinCode
 from pypy.interpreter.argument import Arguments
 from pypy.tool.sourcetools import compile2, func_with_new_name
@@ -106,9 +106,11 @@
             return space.call_args(w_impl, args)
     def call_args(space, w_obj, args):
-        # a special case for performance
+        # two special cases for performance
         if isinstance(w_obj, Function):
             return w_obj.call_args(args)
+        if isinstance(w_obj, Method):
+            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