5 ms·
So we have: * Statically allocated ("frozen") core modules for fast imports * Avoid memory allocation for frames / faster frame creation * Inlined python fun
by missblit 4y ago
So we have:
* Statically allocated ("frozen") core modules for fast imports
* Avoid memory allocation for frames / faster frame creation
* Inlined python functions are called in pure python without needing to jump through C
* Optimizations that take advantage of speculative typing (Reminds me of Javascript JIT compilers -- though according to the FAQ Python isn't JIT yet)
* Smaller memory usage for frames, objects, and exceptions
Dang that certainly does sound like low hanging fruit. There's probably a lot more opportunities left if they want Python to go even faster.
- dagmx 4y agoThings may seem like low hanging fruit in the abstract bullet point, but the work needed may be immense.
- FartyMcFarter 4y ago> Inlined python functions are called in pure python without needing to jump through C 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?
- liuliu 4y agoIt seems to be just previously, it does: 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.
- enragedcacti 4y agoIt's a little confusing but I don't think they meant inlining in the traditional sense. its more like they inlined the C function wrapper around python functions. > 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.
- outworlder 4y ago> Given that Python is interpreted, it's quite unclear what this could mean. Python is compiled. CPython runs bytecode. (If Python is interpreted, then so is Java without the JIT).
- FartyMcFarter 4y agoFair enough, but that doesn't help understanding the original sentence.
- gpderetta 4y agoI don't think that calling non-JITed Java 'interpreted' is in any way controversial.