问题
Is the PyPy GIL part of the PyPy interpreter implementation in RPython, or is it something that translate.py automatically adds? i.e., if I were to write my own new language interpreter in RPython and ran it through translate.py, would it be subject to the GIL a priori, or would that be up to my interpreter code?
回答1:
The GIL handling is inserted by module/thread/gil.py in your PyPy checkout. It's an optional translation feature and it's only added when thread module is enabled. That said, RPython itself is not a thread-safe language (like for example C), so you would need to take care yourself to lock objects correctly, so they don't come up inconsistent. The main issue would be to provide a thread-aware garbage collector, because the one that we use right now is not thread safe and just adding a lock would remove a whole lot of benefits from a free-threading model.
Cheers, fijal
来源:https://stackoverflow.com/questions/12166268/wheres-the-gil-in-pypy