Martin Manns wrote:

> Thanks for pointing out the oversimplified nature of the original
> example.I hope that the following one clarifies the problem.
> 
> (I do not know, what has to be stored on the stack, but it should not be
> that much, because all recursion calls originate from inside the return
> statement.)

> class Node(object):
>     def __init__(self):
>         self.state = abs(randint(1,1000))
>     def GetDepState(self):
>         return self.state + max(s.GetDepState() for s in S[self])
> 
> class ConditionalBreakNode(Node):
>     def GetDepState(self):
>         if randint(1,5) > 1:
>             return Node.GetDepState(self)
>         else:
>             return self.state

Have you investigated the libraries available for that kind of problem? (No,
I don't know them) Maybe one of them provides an implementation that does
not depend on the stack.

On the other hand, if the above is the "natural" expression of your problem,
why not give stackless a try?

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to