I have two functions each calling the other on their final line as a means of passing control. Is there an elegant way to force one function to exit before the other gets executed, so that you don't stack your program up on corpses?
Example:
def f1(x):
print("f1",x)
f2(x+1)
def f2(x):
print("f2",x)
f1(x+1)
f1(0)
The way it is now, after ~1000 calls it runs into the recursion limit.
Of cause, a simple external control structure would get rid of the problem, but I'd rather have the control flow engraved in the functions.
Edit:
But isn't this rather hindering?
If Python strives to be a high-level language with a high level of abstraction, at some point of building modules upon modules, wouldn't Python collapse on its own behavior of not reducing its footprint?