mirror of https://github.com/python/cpython
add a contextmanager to disable the gc
This commit is contained in:
parent
c917494528
commit
31f4beb15e
|
@ -1005,6 +1005,16 @@ def gc_collect():
|
|||
gc.collect()
|
||||
gc.collect()
|
||||
|
||||
@contextlib.contextmanager
|
||||
def disable_gc():
|
||||
have_gc = gc.isenabled()
|
||||
gc.disable()
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if have_gc:
|
||||
gc.enable()
|
||||
|
||||
|
||||
def python_is_optimized():
|
||||
"""Find if Python was built with optimizations."""
|
||||
|
|
Loading…
Reference in New Issue