Possibly Pythonic Tail Call Optimization (TCO/TRE)

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Jul 17 01:41:39 CEST 2015


Joonas Liik wrote:
> https://docs.python.org/2/library/sys.html#sys.setrecursionlimit
> so as per the docs the programmer has no real control over how much
> stack his program can have. all you can say is "let me ignore the
> safeguard a little longer, i hope i wont crash the program" that is
> not the same as "can i please have a stack depth of 20000..

I don't think there's much that can be done about that.

If CPython doesn't impose an artificial limit, then it's at
the mercy of the C compiler and runtime system as to the
handling of stack overflows.

The only way for CPython to take total control of the stack
situation would be to get the C stack out of the picture
altogether, using techniques such as the original Stackless
Python employed. But the BDFL has ruled out CPython ever
going that way, because it would massively warp the C API.

-- 
Greg


More information about the Python-list mailing list