Teaching : Python, Scheme, Java...

Bengt Richter bokr at oz.net
Thu Apr 17 17:53:25 EDT 2003


On Thu, 17 Apr 2003 09:55:46 +0200, Jean-Paul Roy <roy at unice.fr> wrote:
[...]
>- Pyhton is bad : recursion limit (I am astonished at that one)
I think it's just there to warn you, so you don't have to wait so long
or get potentially confusing OOM symptoms before you realize you've got
a lot of recursion. You can adjust the limit.

 >>> import sys
 >>> help(sys.setrecursionlimit)
 Help on built-in function setrecursionlimit:

 setrecursionlimit(...)
     setrecursionlimit(n)

     Set the maximum depth of the Python interpreter stack to n.  This
     limit prevents infinite recursion from causing an overflow of the C
     stack and crashing Python.  The highest possible limit is platform-
     dependent.

 >>> help(sys.getrecursionlimit)
 Help on built-in function getrecursionlimit:

 getrecursionlimit(...)
     getrecursionlimit()

     Return the current value of the recursion limit, the maximum depth
     of the Python interpreter stack.  This limit prevents infinite
     recursion from causing an overflow of the C stack and crashing Python.

 >>> sys.getrecursionlimit()
 1000

The latter is the default on the 2.2.2 windows version.

Regards,
Bengt Richter




More information about the Python-list mailing list