maximum recursion depth

Paul phsdv.remove at earthlink.net
Sun Jul 21 18:02:47 EDT 2002


I think I will rewrite my code using loops. This will be possible, I just
have to put my braincells back in active mode :-)
I found that a too deep recursion will slow down executing to much.
For now my program works with the recursion limit set at 3000.
However I can think of situations where this will not be enough.

For the statistics, I am using win2000 + cygwin (i686-pc-cygwin)
Python 2.2 (#1, Dec 31 2001, 15:21:18)
[GCC 2.95.3-5 (cygwin special)] on cygwin

Paul

"Tim Peters" <tim.one at comcast.net> wrote in message
news:mailman.1027283309.29075.python-list at python.org...
> [Paul, recursing very deeply]
> > unfortunately it is not just memory...
> > it will (did) crash when the stack size is full, which is only a
> > fraction of the total memory space... right?
>
> The size of the stack you get depends on your operating system, and
perhaps
> also your platform C runtime implementation -- it's not Python's decision.
> If you tell us which OS you're using, someone may be able to tell you how
to
> tell your OS that you want a larger stack.  If you're using threads too,
> life can get more complicated in a hurry, because most OS thread
> implementations give threads relatively tiny stacks by default.
>
> > python used less than 6MByte (less than 1% of total) when it
> > crashed with a much higher limit set for the recursion depth.
> > It took an awful lot of processing time as well... Have to rethink my
> > strategy here.
>
> Function calls in Python aren't cheap either.  Keeping a stack or queue of
> "work to do" in an iterative algorithm ("a loop") is often much faster.
>
>
>
>





More information about the Python-list mailing list