maximum recursion depth

Alex Martelli aleax at aleax.it
Mon Jul 22 02:23:20 EDT 2002


Paul wrote:

> I think I will rewrite my code using loops. This will be possible, I just
> have to put my braincells back in active mode :-)

Yes, any recursion can be systematically removed.  Easier in a language
with GOTO, but, worst case, one can use the "trivial form of Jacopini-
Böhm" which shows how to map any flow diagram into a while loop with a
switch as the body (if/elif tree as the body, in Python).  Most often,
one can do better in terms of both readability and performance.


Alex




More information about the Python-list mailing list