Why no tailcall-optimization?
Aaron "Castironpi" Brady
castironpi at gmail.com
Mon Sep 22 21:28:37 EDT 2008
On Sep 22, 8:13 pm, process <circularf... at gmail.com> wrote:
> Why doesn't Python optimize tailcalls? Are there plans for it?
>
> I know GvR dislikes some of the functional additions like reduce and
> Python is supposedly about "one preferrable way of doing things" but
> not being able to use recursion properly is just a big pain in the
> a**.
I didn't think this through completely-- is it incompatible with
closures and local function definitions?
def f( m ):
def g( n ):
return m+ n
stuff( )
return g( 0 )
In this case, the stack, growing up:
g
f
main
is not equivalent to:
g
main
in the last step, due to the local definition of 'm' in 'f'.
More information about the Python-list
mailing list