[issue31356] Add context manager to temporarily disable GC
Bar Harel
report at bugs.python.org
Mon Jan 18 13:33:34 EST 2021
Bar Harel <bzvi7919 at gmail.com> added the comment:
I've taken a shot making this in pure Python, and took into account a few more factors such as starvation and reentrancy.
As Nick said, one of the only ways it can truly work is if it's completely global, in which case we don't need to use the internal lock and relying on the GIL would work.
It's not very efficient atm, as the overhead of the Lock() and
resulting python code probably offsets the benefit of disabling the GC, but it can be fine for some uses I guess.
https://github.com/bharel/disable_gc
I'll release it to pypi sometime soon and we can take a look at the not-so-accurate usage metric to see if such a thing is needed in the standard library.
----------
nosy: -Dennis Sweeney
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31356>
_______________________________________
More information about the Python-bugs-list
mailing list