@contextlib.contextmanager
def change_recursion_limit(limit):
 old_limit = sys.getrecursionlimit()
 if (old_limit < limit):
  sys.setrecursionlimit(limit)
 (yield)
 sys.setrecursionlimit(old_limit)

@ contextlib . contextmanager def change_recursion_limit ( limit ) : old_limit = sys . getrecursionlimit ( ) if ( old_limit < limit ) : sys . setrecursionlimit ( limit ) ( yield ) sys . setrecursionlimit ( old_limit )
temporarily changes the recursion limit .