]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add a second special case to the inline function call code in eval_code2().
authorJeremy Hylton <jeremy@alum.mit.edu>
Fri, 18 May 2001 20:53:14 +0000 (20:53 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Fri, 18 May 2001 20:53:14 +0000 (20:53 +0000)
If we have a PyCFunction (builtin) and it is METH_VARARGS only, load
the args and dispatch to call_cfunction() directly.  This provides a
small speedup for perhaps the most common function calls -- builtins.

Python/ceval.c

index 0cdd0199b965e10df1b5b1e3e371079a3010be00..e407de49a953de45609d70c7b1190cdcdd7b2a96 100644 (file)
@@ -1969,7 +1969,13 @@ eval_code2(PyCodeObject *co, PyObject *globals, PyObject *locals,
                       callable object.
                    */
                    if (PyCFunction_Check(func)) {
-                           if (PyCFunction_GET_FLAGS(func) == 0) {
+                           int flags = PyCFunction_GET_FLAGS(func);
+                           if (flags == METH_VARARGS) {
+                                   PyObject *callargs;
+                                   callargs = load_args(&stack_pointer, na);
+                                   x = call_cfunction(func, callargs, NULL);
+                                   Py_XDECREF(callargs); 
+                           } else if (flags == 0) {
                                    x = fast_cfunction(func,
                                                       &stack_pointer, na);
                            } else {