@contextmanager
def gc_state(state):
 orig_state = gc.isenabled()
 set_gc_state(state)
 (yield)
 set_gc_state(orig_state)

@ contextmanager def gc_state ( state ) : orig_state = gc . isenabled ( ) set_gc_state ( state ) ( yield ) set_gc_state ( orig_state )
context manager to set state of garbage collector to state parameters state : bool true for gc enabled .