[Python-Dev] Re: Proper tail recursion

Christian Tismer tismer at stackless.com
Mon Jul 19 23:17:36 CEST 2004

David Eppstein wrote:

> In article <005701c46db5$764b48d0$6602a8c0 at arkdesktop>,
>  "Andrew Koenig" <ark-mlist at att.net> wrote:
>>>I also haven't seen the use case that requires this and couldn't
>>>easily be fixed by changing the data structure or code slightly.
>>>(Andrew Koenig's theoretical objections don't count as use cases.)
>>Didn't we just hear that this problem affects pickling?
> We heard that the recursion limit prevents recursive DFS from being 
> applied to large graphs, and that pickling uses DFS.  However, tail 
> recursion wouldn't help in this case -- it's a deep recursion but not a 
> tail recursion.

[dropping interesting details for my brute-force solution]

I went a different and very simple path for Stackless:
When cPickle goes too deep, I simply allocate a new C stack
and let it continue. That was the simplest possible patch
for me, since I only wanted it to no longer crash.
Not that this is not needed for unpickling; this structure
is as flat as it can be.

ciao - chris

Christian Tismer             :^)   <mailto:tismer at stackless.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/

More information about the Python-Dev mailing list