Feature or enhancement
CPython uses freelists for frequently allocated Python objects, like dict, list, and slice. There freelists are generally stored in the per-interpreter state, which is not thread-safe without the GIL. In --disable-gil builds, the freelists should be stored in the per-thread state (i.e., PyThreadState). I think we probably want to keep the freelists in the interpreter state for the default build. This will probably require some refactoring.
Freelists:
float
slice (slice_cache)
tuple
list
dict (PyDictKeysObject and PyDictObject)
generator (value_freelist and asend_freelist)
PyContext
For context, here are similar changes in the nogil-3.12 fork, but I expect the changes in CPython 3.13 to be a bit different:
Linked PRs
Feature or enhancement
CPython uses freelists for frequently allocated Python objects, like
dict,list, andslice. There freelists are generally stored in the per-interpreter state, which is not thread-safe without the GIL. In--disable-gilbuilds, the freelists should be stored in the per-thread state (i.e.,PyThreadState). I think we probably want to keep the freelists in the interpreter state for the default build. This will probably require some refactoring.Freelists:
floatslice(slice_cache)tuplelistdict(PyDictKeysObjectandPyDictObject)generator(value_freelistandasend_freelist)PyContextFor context, here are similar changes in the
nogil-3.12fork, but I expect the changes in CPython 3.13 to be a bit different:Linked PRs