Proper tail recursion
Christopher T King
squirrel at WPI.EDU
Tue Jul 6 09:06:32 EDT 2004
Is it feasable, and/or desirable to have Python optimize tail-recursive
calls, similar to Scheme and gcc -O2? i.e. effectively compile this:
def foo(n):
return foo(n-1)
into this:
def foo(n):
goto foo(n-1)
This would naturally only be enabled in optimized bytecode.
On an unrelated, Scheme-ish note, is there any way for a generator to
access itself? i.e. I want to be able to write this:
def gen():
yield get_current_continuation(),someothergenerator()
Thanks,
Chris
More information about the Python-list
mailing list