Distinguish Free-Threaded Builds and Subinterpreters
Core idea
CPython 3.13 introduced an experimental optional free-threaded build; Python 3.14 provides supported optional free threading. Build capability is distinct from current GIL state: an extension may re-enable it. sysconfig.get_config_var("Py_GIL_DISABLED") checks build capability, and sys._is_gil_enabled() reports current state on CPython 3.13+. Python 3.14 introduces the public concurrent.interpreters API and InterpreterPoolExecutor; interpreters isolate module state, while separate threads enable parallel work. These are version-specific features.
import sysconfigflag = sysconfig.get_config_var('Py_GIL_DISABLED')supports_free_threading = flag == 1print(isinstance(supports_free_threading, bool))Print the type of the classification for portable expected output. Inspect the actual flag locally to learn which build is running.
Expected output:
TrueInspect current GIL state
import sysprobe = getattr(sys, '_is_gil_enabled', None)if probe is None: print('probe unavailable')else: print(type(probe()).__name__)On CPython 3.13 the probe returns a boolean, not a guarantee about thread safety. The actual value is environment-dependent.
Expected output:
boolCommon mistake
Do not remove synchronization when using a free-threaded build. Subinterpreters are not transparent shared-object workers or a security sandbox; extension compatibility and supported communication matter. The 3.14 APIs are discussed but not executed on this 3.13 runtime.
Practice
Record actual build flag and GIL state on a local CPython installation. On a separate supported 3.14 runtime, investigate interpreter isolation using the official concurrent.interpreters examples; record version and results separately.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Free-threaded builds and subinterpreters
Check your understanding of free-threaded builds and subinterpreters.
What is printed?
import sysconfigprint(type(sysconfig.get_config_var("Py_GIL_DISABLED") == 1).__name__)What is printed?
import sysprint(callable(getattr(sys,"_is_gil_enabled",None)))Can a free-threaded-capable build have its GIL enabled?
Which version introduced the public concurrent.interpreters module?