C Extensions: Biggest GIL-Free Compatibility Hurdle

Existing C-API extensions require rebuilding for the `--disable-gil` Python build, potentially needing explicit locking for thread safety and publishing under a new 't' ABI tag for wheels.

The top 3

  1. C Extensions' ABI Break: The GIL-Free Rebuild Mandate: Removing the GIL necessitates changes to Python's object header, making GIL-free CPython builds ABI-incompatible with standard versions, thus requiring all C extensions to be rebuilt and re-linked for compatibility.
  2. Python's C-API Reliance: Top Libraries' Thread Safety Overhaul: Core data science libraries like NumPy, Pandas, and SciPy, which heavily leverage C extensions, face significant re-engineering to ensure thread-safe operations and explicit locking without the GIL's implicit protection.
  3. Explicit GIL-Free Support: New C APIs for Extension Compatibility: C extensions must explicitly declare GIL-free compatibility using new mechanisms like the `Py_mod_gil` slot or `PyUnstable_Module_SetGIL()`, alongside adopting new C APIs for thread-safe object and memory management.

Sources

Open the full topic