diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-11-28 17:32:31 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-11-28 17:32:31 (GMT) |
commit | b69ee8c38642a4efd0b880f0c8651010aa7883b9 (patch) | |
tree | 4685bc149aaf434d5bec65804397a348d7b53ef0 | |
parent | 213cc388c79c71d2f4a2f5cf9dbb29cd03e2eff9 (diff) | |
download | cpython-b69ee8c38642a4efd0b880f0c8651010aa7883b9.zip cpython-b69ee8c38642a4efd0b880f0c8651010aa7883b9.tar.gz cpython-b69ee8c38642a4efd0b880f0c8651010aa7883b9.tar.bz2 |
call_function(): document PyMethod optimization
-rw-r--r-- | Python/ceval.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 569c609..42c0c61 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4736,7 +4736,11 @@ call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames) } else { if (PyMethod_Check(func) && PyMethod_GET_SELF(func) != NULL) { - /* optimize access to bound methods */ + /* Optimize access to bound methods. Reuse the Python stack + to pass 'self' as the first argument, replace 'func' + with 'self'. It avoids the creation of a new temporary tuple + for arguments (to replace func with self) when the method uses + FASTCALL. */ PyObject *self = PyMethod_GET_SELF(func); Py_INCREF(self); func = PyMethod_GET_FUNCTION(func); |