Skip to content

Commit b82a5a6

Browse files
committed
call_function(): document PyMethod optimization
1 parent 9dc3eda commit b82a5a6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Python/ceval.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -4736,7 +4736,11 @@ call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
47364736
}
47374737
else {
47384738
if (PyMethod_Check(func) && PyMethod_GET_SELF(func) != NULL) {
4739-
/* optimize access to bound methods */
4739+
/* Optimize access to bound methods. Reuse the Python stack
4740+
to pass 'self' as the first argument, replace 'func'
4741+
with 'self'. It avoids the creation of a new temporary tuple
4742+
for arguments (to replace func with self) when the method uses
4743+
FASTCALL. */
47404744
PyObject *self = PyMethod_GET_SELF(func);
47414745
Py_INCREF(self);
47424746
func = PyMethod_GET_FUNCTION(func);

0 commit comments

Comments
 (0)