Re:Python 3.11 beta vs. 3.10 benchmark
by SemanticStrengh on Wednesday May 18, 2022 @08:14AM
(#31421800)
BTW It'd be nice if python implemented support for tail call recursive or even better, a growable/segmented stack in order to allow arbitrary pythons functions be stack overflow safe.
e.g. https://gcc.gnu.org/wiki/SplitStacks#:~:text=Split%20Stacks%....
There was once stackless python that did this (Eve online was built in it), I don’t know if it still exists though.
Re:Python 3.11 beta vs. 3.10 benchmark
by bqmjjx0kac on Wednesday May 18, 2022 @09:18AM
(#31422396)
Neat! https://en.wikipedia.org/wiki/Stackless_Python
Sadly, it isn't true parallelism, more like green threads. And they didn't manage to kill the GIL.
Re:Python 3.11 beta vs. 3.10 benchmark
by FreakLegion on Thursday May 19, 2022 @12:35AM
(#31430818)
With Python it's possible to do tail-call optimization yourself. See this all-time great Stack Overflow answer and the linked repo for details (the actual code is quite short): https://stackoverflow.com/a/18506625.
If Python doesn't depend on the C stack anymore (for most of its work), that's basically what you'll have for free.
Python's own stackframes are heap-allocated and chained (so each function has its own stack, in essence), so its use of a single unified allocation space for stack is already an implementation detail of the interpreter.
Re:Python 3.11 beta vs. 3.10 benchmark
by SemanticStrengh on Wednesday May 18, 2022 @04:02PM
(#31426992)
nice
> 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.
https://docs.python.org/3.11/whatsnew/3.11.html#inlined-pyth...