[issue31356] Add context manager to temporarily disable GC
Yury Selivanov
report at bugs.python.org
Wed Jan 31 13:00:16 EST 2018
Yury Selivanov <yselivanov at gmail.com> added the comment:
A few thoughts:
1. The merged PR releases GIL for any Python code run in `with gc.ensure_disabled()`. This is just plain wrong.
2. The merged PR crashes on debug build of CPython.
3. I don't actually understand this feature. Our GC is not per OS thread, which means that inside `with gc.ensure_disabled()` the GC can become suddenly **enabled**, if another thread enables it. This API is just misleading (maybe the name of the new context manager is bad—it cannot ensure anything). There's even a unittest that tests this!
4. This new API can be trivially implemented in pure Python:
@contextmanager
def disable_gc():
gc.disable()
try:
yield
finally:
gc.enable()
5. While such pure Python version shares the problem discussed in (3), the currently committed C implementation doesn't fix them either.
IMO this entire issue needs to be properly debated on python-ideas first and the PR should be reverted from beta-1. If the latter is not possible, OK, let's revert it for beta-2 and for 3.8.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31356>
_______________________________________
More information about the Python-bugs-list
mailing list