summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorINADA Naoki <songofacandy@gmail.com>2017-02-02 22:43:03 (GMT)
committerINADA Naoki <songofacandy@gmail.com>2017-02-02 22:43:03 (GMT)
commit5566bbb8d563646d83e8172410fa0c085e8233b1 (patch)
treecb8ca83c2b1a6eb01a6b51258532b4fccf548b6d /Python
parent144fff8b900f9d452402a8e47ff79e88e4916d28 (diff)
downloadcpython-5566bbb8d563646d83e8172410fa0c085e8233b1.zip
cpython-5566bbb8d563646d83e8172410fa0c085e8233b1.tar.gz
cpython-5566bbb8d563646d83e8172410fa0c085e8233b1.tar.bz2
Issue #29263: LOAD_METHOD support for C methods
Calling builtin method is at most 10% faster.
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 298ad55..5800779 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);
}