Official means to release the GIL in Python

The GIL has been a widely discussed topic in the Python community. It's has it's advantages and disadvantages. I was suggesting that an official way be placed in the Python threading module to release the GIL if one needs to perform some tasks that don't need the GIL. It could be something as simple as thd = threading.Thread(target = encrypt, nogil = True) I saw a nogil option in Cython, I just thought it would be great to have it fully support in Python as we await the results from Sam Gross's paper.

On 3 Dec 2021, at 15:23, TobiasHT <higenyi.tobias@gmail.com> wrote:
The GIL has been a widely discussed topic in the Python community. It's has it's advantages and disadvantages. I was suggesting that an official way be placed in the Python threading module to release the GIL if one needs to perform some tasks that don't need the GIL.
It could be something as simple as
thd = threading.Thread(target = encrypt, nogil = True)
I saw a nogil option in Cython, I just thought it would be great to have it fully support in Python as we await the results from Sam Gross's paper.
You must hold the GIL to execute python code. Only extensions written in C etc can release the GIL while they do work that does not access any python API. Cython generates C code I believe and can release the GIL because it I’d not python code. In other words this cannot be made to work. Barry
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5PWD7M... Code of Conduct: http://python.org/psf/codeofconduct/
participants (2)
-
Barry
-
TobiasHT