]> granicus.if.org Git - python/commitdiff
call_function(): document PyMethod optimization
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 28 Nov 2016 17:32:31 +0000 (18:32 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 28 Nov 2016 17:32:31 +0000 (18:32 +0100)
Python/ceval.c

index 569c609979a58b1b0c309f4f8b750c4b2bd8192a..42c0c614b1d7086831694f46795ded4d6cecda33 100644 (file)
@@ -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);