Maximum recursion depth in python

Christian Tismer tismer at tismer.com
Sun Nov 5 10:05:15 EST 2000


Ruud de Rooij wrote:
> 
> aahz at panix.com (Aahz Maruch) writes:
> 
> > I believe that
> > Stackless Python has no recursion limits.
> 
> Of course it has.  The recursion depth is necessarily limited by the
> amount of memory available.

Yes. Limited by available memory is the usually auto-applied
substitution macro when one reads "no limits".

Of course you might argue that the size of the C stack is also
just an arbitrary thing that could be made as large as you want,
but that's not so practical.

Aside, recursion can be completely unlimited if keeping the
program state can be done with a finite amount of memory.
To be able to do this, your program must be re-written
using tail-recursion, and the number of continuations
to be kept must be finite. This is not always possible,
also we don't have tail recursion in Python yet.
(but I believe it is possible, to some extent).

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com




More information about the Python-list mailing list