Tail recursion to while iteration in 2 easy steps

Alain Ketterlin alain at dpt-info.u-strasbg.fr
Fri Oct 4 05:49:26 EDT 2013


Mark Janssen <dreamingforward at gmail.com> writes:

>>>>> def fact(n): return 1 if n <= 1 else n * fact(n-1)

>> class Strange:
>>   ...
>>   def __le__(dummy):
>>     global fact
>>     fact = someotherfun # this is "binding"
>>     return false

>> You cannot prevent this in python.

> No, but you can't prevent a lot of bad moves in python.  What you just
> did there is a total bonehead ("strange"?) of an idea.

I think allowing rebinding of function names is extremely strange, even
though it's easier to implement. I tend to agree with you on the quality
of the idea, but optimization has to take this into account (and give
up, usually).

-- Alain.



More information about the Python-list mailing list