from time import time from sys import setrecursionlimit from functools import lru_cache setrecursionlimit(10000000) def consumer(gen): for x in gen: pass def recurse(i): if i < 0: return consumer(recurse(j) for j in [i-1]) lo = 8 hi = 16 t = {} for sh in range(lo, hi): b4 = time() x = 1 << sh ret = recurse(x) after = time() t[sh] = after - b4 for sh in range(lo+1, hi): print(t[sh] / t[sh-1])