Description
Feature or enhancement
The free-threaded builds require substantial changes to the garbage collection implementation, but we don't want to make those changes to the default build. In other parts of CPython, we have used "local" #ifdef Py_GIL_DISABLED
guards around free-threaded specific bits, but I think doing this throughout Modules/gcmodule.c
will make the GC harder to maintain than having separate files for the free-threaded and default builds. Additionally, I think @markshannon already suggested splitting the core GC parts from the Python "gc" module.
There's definitely an increased maintenance cost for having two GC implementations in separate files, but I think this maintenance will be less than having a single file with intermixed implementations and lots of #ifdef Py_GIL_DISABLED
guards.
Here's a proposed split:
Modules/gcmodule.c
- gc
Python package interface
Python/gc.c
- core GC functionality common to both build configurations (GIL & free-threaded)
Python/gc_gil.c
- GIL (non-free-threaded) specific implementations
Python/gc_free_threaded.c
- free-threaded specific implementations
At first, I'd expect most code to be in either Modules/gcmodule.c
or Python/gc.c
. As work on the free-threaded build continues, I would expect Python/gc.c
to shrink as code is moved into Python/gc_gil.c
and Python/gc_free_threaded.c
.
@nascheme @markshannon @pablogsal @DinoV @vstinner
Activity