Where's the GIL in PyPy?

会有一股神秘感。 提交于 2019-12-08 15:25:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!