[Tutor] maximum recursion depth exceeded !

Alan G alan.gauld at freenet.co.uk
Thu Jul 7 22:50:47 CEST 2005


> I wrote a recursive function a got this error how can 
> I increase maximum recursion depth. 

You have to go into the Python source code and change a 
value then rebuild Python.

> And what is its default value?

1000 last time I looked.

But beware that increasing it too far can result in 
significant memory usage, which is why there is a limit 
in the first place. Recursion is a powerful tool but 
can quickly run away with your PC resources. Although 
with modern machines you can probably increase the 
limit to 10000 without serious problems - but I've 
never tried!

Maybe someday someone will convert Python to implement 
tail-end recursion...

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld






More information about the Tutor mailing list