PyYAML-ft is a fork of the popular PyYAML library, providing a full-featured YAML parser and emitter for Python. Its primary purpose is to add support for free-threading builds of CPython, specifically targeting Python 3.13 and newer, where the Global Interpreter Lock (GIL) is absent. This addresses thread-safety issues that are more easily triggered in free-threaded environments and ensures ABI compatibility. The library is currently at version 8.0.0 and maintains an active release cadence in sync with free-threading Python developments.
pip install pyyaml-ftVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to load and dump YAML data using `pyyaml-ft`. It includes a conditional import for compatibility and uses `safe_load`/`safe_dump` for secure processing of YAML data.
Update imports to `import yaml_ft` or use `try: import yaml_ft as yaml except ModuleNotFoundError: import yaml` for compatibility with projects supporting both PyYAML and PyYAML-ft.
Ensure that any custom YAML types or resolvers are registered within each thread's initialization function or before processing YAML in that thread.
Ensure your project's `requires_python` is set to `>=3.13` and consider conditional installation based on `python_version` if supporting a wider range of Python versions.
Always use `yaml_ft.safe_load()` when loading YAML from untrusted or external sources to restrict object construction to safe types.