Search This Blog

Saturday, May 23, 2009

Increase Python Recursion Limit

If recursion in Python is too deep, it will throw this error:
RuntimeError: maximum recursion depth exceeded

This can be solved by increasing the recursion limit

import sys

However, the default limit is there for a reason. The limit can prevent infinite recursion from overflowing the C stack. This will crash Python.

No comments: