← Back to Python, page 5

python-0099 · Hard senior

What is the free-threaded build of Python 3.13, and how should a senior engineer evaluate it?

Python 3.13 ships an optional experimental build (python3.13t) with the GIL disabled, so threads can run Python code on several cores at once. The standard build still has the GIL. Evaluate it by checking that C extensions support it, measuring real workloads (single-threaded code runs slower in 3.13t), and auditing code that relied on the GIL for implicit thread safety.

Full answer
python
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:

text
(3, 13)
GIL enabled: True
free-threaded build: False

The 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.

python
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