mirror of
https://github.com/python/cpython.git
synced 2025-10-15 19:29:46 +00:00
add a contextmanager to disable the gc
This commit is contained in:
parent
c917494528
commit
31f4beb15e
1 changed files with 10 additions and 0 deletions
|
@ -1005,6 +1005,16 @@ def gc_collect():
|
||||||
gc.collect()
|
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():
|
def python_is_optimized():
|
||||||
"""Find if Python was built with optimizations."""
|
"""Find if Python was built with optimizations."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue