> During a Python function call, Python will call an evaluating C function to interpret that function’s code. This effectively limits pure Python recursion to what’s safe for the C stack.
> In 3.11, when CPython detects Python code calling another Python function, it sets up a new frame, and “jumps” to the new code inside the new frame. This avoids calling the C interpreting function altogether.
> Most Python function calls now consume no C stack space. This speeds up most of such calls. In simple recursive functions like fibonacci or factorial, a 1.7x speedup was observed. This also means recursive functions can recurse significantly deeper (if the user increases the recursion limit). We measured a 1-3% improvement in pyperformance.
switch (op) {
case "call_function":
interpret(op.function)
...
}
Now it does: switch (op) {
case "call_function":
... setup frame objects etc ...
pc = op.function
continue
....
}
Not sure if they just "inlined" it or use tail-call elimination trick.Python is compiled. CPython runs bytecode.
(If Python is interpreted, then so is Java without the JIT).
Given that Python is interpreted, it's quite unclear what this could mean.
Also, what does it mean to "call" an inlined function?? Isn't the point of inline functions that they don't get called at all?