From a quick look it seems like the main issue will be synchronizing access to the Pool state. So perhaps:
- A per-instance
std::mutex (from libcpp.mutex) within the cymem.Pool class.
alloc etc. will be protected by the C++ mutex using lock_guard and with nogil: before acquiring the mutex (so we don't deadlock with the GIL).
Pool.realloc might need a different approach / refactor, since we can't recursively have lock acquisition.
- Py_INCREF/Py_DECREF is imported by unused, might be needed for
own_pyref and __dealloc__.
The standard TODOs for adding free-threading support are:
For more details, please see the suggested plan of attack in the py-free-threading guide.
Note that this is the first time I've looked at this repo, so I might be
missing known issues or code that needs closer inspection. Any suggestions here
will be very useful.
Let me know if I ought to hold off for any reason. One thing which is slightly concerning is that there are few in-project tests.
From a quick look it seems like the main issue will be synchronizing access to the
Poolstate. So perhaps:std::mutex(fromlibcpp.mutex) within thecymem.Poolclass.allocetc. will be protected by the C++ mutex usinglock_guardandwith nogil:before acquiring the mutex (so we don't deadlock with the GIL).Pool.reallocmight need a different approach / refactor, since we can't recursively have lock acquisition.own_pyrefand__dealloc__.The standard TODOs for adding free-threading support are:
pytest-run-parallelto find potential issues, and fix them.cp313t-*to CI to build free-threading wheels.For more details, please see the suggested plan of attack in the py-free-threading guide.
Note that this is the first time I've looked at this repo, so I might be
missing known issues or code that needs closer inspection. Any suggestions here
will be very useful.
Let me know if I ought to hold off for any reason. One thing which is slightly concerning is that there are few in-project tests.