示例工程 21-free-threading-concurrency-choice
21-free-threading-concurrency-choice/01-detect-gil/README.md
# 01 · detect-gil
**演示**:用 `sys._is_gil_enabled()`(3.13+)与 `sysconfig` 的 `Py_GIL_DISABLED` 判断当前解释器是否启用 GIL。3.12 没有 `_is_gil_enabled`,回退为 `True`。
**运行**:
```sh
uv run python examples/21-free-threading-concurrency-choice/01-detect-gil/detect_gil.py
```
**预期输出**(3.12.9):
```text
python: 3.12.9
gil_enabled: True
Py_GIL_DISABLED: None
free_threaded_build: False
```
**依赖**:仅标准库。
**注意**:标准 3.13/3.14 构建仍是 GIL 版;free-threaded 构建在 3.13 是实验性,3.14 起为受支持构建(PEP 779),需要用 `uv python install 3.14t` 之类的变体显式安装。