Tail recursion to while iteration in 2 easy steps

rusi rustompmody at gmail.com
Fri Oct 4 06:52:30 EDT 2013


On Thursday, October 3, 2013 10:57:48 PM UTC+5:30, Ravi Sahni wrote:
> On Wed, Oct 2, 2013 at 10:46 AM, rusi wrote:
> > 4. There is a whole spectrum of such optimizaitons --
> > 4a eg a single-call structural recursion example, does not need to push return address on the stack. It only needs to store the recursion depth:
> >
> > If zero jump to outside return add; if > 0 jump to internal return address
> >
> > 4b An example like quicksort in which one call is a tail call can be optimized with your optimization and the other, inner one with 4a above
> 
> 
> I am interested in studying more this 'whole spectrum of optimizations'
> Any further pointers?

Mmm… Bummer…

There was a book having these -- at least 5-6 different optimizations of which tail-call was the most obvious. Maybe author was McGettrick dont remember for sure... Probably 20 years now!

I'll try and re-remember them and post.



More information about the Python-list mailing list