scoder / fastrlock

A fast RLock implementation for CPython
MIT License
23 stars 10 forks source link

Free-threaded Python support #19

Open szalpal opened 5 months ago

szalpal commented 5 months ago

Hi,

Recently PEP 703 has been approved, which removes the GIL in Python. The timeline of the change is far, however I'd like to ask, is there a particular plan of fastrlock working without the GIL?

I'm particularly asking, since from the How does it work section I understand that fastrlock is inherently coupled with GIL.

Ideally fastrlock API might stay unchanged, so that any project using fastrlock does not require code changes.

scoder commented 5 months ago

In nogil CPython (which has already landed in CPython 3.13), you can probably just use threading.RLock instead – unless you're asking about fastrlock's C-API.

The change that CPython needed seems to be this: https://github.com/python/cpython/commit/f366e215044e348659df814c27bf70e78907df21 It uses atomics, which seems reasonable.

The same can probably be implemented for fastrlock. PR welcome.