I currently use this code:
def f():
try:
f()
except RecursionError:
f()
try:
f()
except RecursionError:
f()
This results in a fatal stack overflow instantly. However, I was wondering if there is an easier way to do this which is much more Pythonic.
MemoryError(but only after waiting for your system to go through swap hell for a while, at least in 64-bit), and in Jython you should get a (catchable) Java StackOverflowError rather than a fatal crash.