summaryrefslogtreecommitdiff
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorINADA Naoki <songofacandy@gmail.com>2017-02-03 07:43:03 +0900
committerINADA Naoki <songofacandy@gmail.com>2017-02-03 07:43:03 +0900
commit99c092a531abf57a8f5c37356dc6971cdfed497a (patch)
tree3fdbd35d564003f85f11a9e1bf37baee3f932321 /Python/ceval.c
parent039f1495e853018c3a7024b843a138f8b4161b6d (diff)
downloadcpython-99c092a531abf57a8f5c37356dc6971cdfed497a.tar.gz
Issue #29263: LOAD_METHOD support for C methods
Calling builtin method is at most 10% faster.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 298ad55b81..58007793bb 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -4832,17 +4832,19 @@ call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
PyObject *x, *w;
Py_ssize_t nkwargs = (kwnames == NULL) ? 0 : PyTuple_GET_SIZE(kwnames);
Py_ssize_t nargs = oparg - nkwargs;
- PyObject **stack;
+ PyObject **stack = (*pp_stack) - nargs - nkwargs;
/* Always dispatch PyCFunction first, because these are
presumed to be the most frequent callable object.
*/
if (PyCFunction_Check(func)) {
PyThreadState *tstate = PyThreadState_GET();
-
- stack = (*pp_stack) - nargs - nkwargs;
C_TRACE(x, _PyCFunction_FastCallKeywords(func, stack, nargs, kwnames));
}
+ else if (Py_TYPE(func) == &PyMethodDescr_Type) {
+ PyThreadState *tstate = PyThreadState_GET();
+ C_TRACE(x, _PyMethodDescr_FastCallKeywords(func, stack, nargs, kwnames));
+ }
else {
if (PyMethod_Check(func) && PyMethod_GET_SELF(func) != NULL) {
/* Optimize access to bound methods. Reuse the Python stack
@@ -4856,20 +4858,18 @@ call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
Py_INCREF(func);
Py_SETREF(*pfunc, self);
nargs++;
+ stack--;
}
else {
Py_INCREF(func);
}
- stack = (*pp_stack) - nargs - nkwargs;
-
if (PyFunction_Check(func)) {
x = fast_function(func, stack, nargs, kwnames);
}
else {
x = _PyObject_FastCallKeywords(func, stack, nargs, kwnames);
}
-
Py_DECREF(func);
}