summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2001-06-27 13:09:44 (GMT)
committerThomas Wouters <thomas@python.org>2001-06-27 13:09:44 (GMT)
commit7a5b674721161bdc60d375cde69b9372539f9191 (patch)
tree530a429544905b378c0bad878251d57342615488
parentcf547e1b9beae7e160cef47d32f0643a9f0f70d6 (diff)
downloadcpython-7a5b674721161bdc60d375cde69b9372539f9191.zip
cpython-7a5b674721161bdc60d375cde69b9372539f9191.tar.gz
cpython-7a5b674721161bdc60d375cde69b9372539f9191.tar.bz2
Backport Jeremy's checkin 2.244:
Add a second special case to the inline function call code in eval_code2(). 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.
-rw-r--r--Python/ceval.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index b6686b6..64dbf98 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1941,7 +1941,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 {