Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where's the GIL in PyPy?

Tags:

pypy

gil

rpython

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?

like image 290
lobsterism Avatar asked Jan 17 '26 15:01

lobsterism


1 Answers

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

like image 58
fijal Avatar answered Jan 21 '26 09:01

fijal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!