Full answer
import sys, sysconfig
print(sys.version_info[:2])
print("GIL enabled:", sys._is_gil_enabled())
print("free-threaded build:", bool(sysconfig.get_config_var("Py_GIL_DISABLED")))Output:
(3, 13)
GIL enabled: True
free-threaded build: FalseThe box runs the standard 3.13 build, so the GIL is enabled and the build was not compiled for free threading; the free-threaded behaviour itself was not run here. sys._is_gil_enabled() is new in 3.13 and is the runtime check, since even a free-threaded build re-enables the GIL if an incompatible extension module is imported. Evaluation points: CPU-bound thread pools may scale with cores; libraries must publish free-threaded wheels; operations that happened to be atomic under the GIL, such as some read-modify-write patterns, need explicit locks; and single-thread performance is lower in 3.13t. Processes and asyncio remain the safe defaults for most services today.
import sys, sysconfig
print(sys.version_info[:2])
print("GIL enabled:", sys._is_gil_enabled())
print("free-threaded build:", bool(sysconfig.get_config_var("Py_GIL_DISABLED")))Run on Python 3.13.5, twice in fresh interpreters, with identical output.
Key points
- 3.13t is optional and experimental
- Standard builds keep the GIL
- Extensions must support it
- Measure single and multi-threaded performance
- Audit implicit GIL assumptions
Common mistakes
- Assuming 3.13 removed the GIL everywhere
- Switching builds without checking extension support
Follow-ups
- Which workloads benefit most?
- How do free-threaded wheels differ?
Tips
- Mention the runtime check