PyYAML

A full-featured YAML parser and emitter for Python, with C-accelerated bindings

Library
PyPI
v6.0.3
2,958 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
61 /100 Good
Development Activity 44
Maintenance 24
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
78 /100 Good
Architecture 82
Code Quality 78
Innovation 68
Learning Curve 85

PyYAML is the canonical YAML processing library for Python, providing a complete implementation of the YAML 1.1 specification for parsing YAML documents into native Python objects and serializing Python objects back into YAML text. It exposes a small, well-known API — yaml.safe_load, yaml.load, and yaml.dump — that has become the de facto standard for reading and writing configuration files, CI pipelines, Kubernetes manifests, and structured data across the Python ecosystem.

Under the hood, PyYAML is built as a layered pipeline of scanner, parser, composer, constructor, and resolver stages, each independently swappable, and it can optionally link against libyaml (via Cython bindings, CSafeLoader/CDumper) for significantly faster parsing and emitting on large documents. The library ships as pure Python by default so it works everywhere CPython runs, with the C extension as an opt-in performance upgrade.

What You Get

  • A complete YAML 1.1 parser and emitter accessible through yaml.safe_load(), yaml.load(), and yaml.dump()
  • Safe-by-default loading (SafeLoader/safe_load) that only constructs plain Python types, plus FullLoader and the legacy unsafe Loader for advanced tag resolution
  • Optional libyaml-backed CSafeLoader/CDumper classes for significantly faster parsing and emitting of large YAML documents
  • Support for custom YAML tags and Python-specific object serialization via representer/constructor registration
  • A layered, swappable pipeline (Reader, Scanner, Parser, Composer, Constructor, Resolver) that advanced users can extend or subclass

Common Use Cases

  • Loading and validating application configuration files written in YAML
  • Parsing CI/CD pipeline definitions (GitHub Actions, GitLab CI) and Kubernetes/Docker Compose manifests
  • Serializing Python data structures to human-readable YAML for storage or interchange
  • Round-tripping structured data between services or tools that standardize on YAML as their config format

Under The Hood

Architecture PyYAML is organized as a mixin-composed pipeline rather than a monolithic parser: Reader handles raw stream decoding, Scanner tokenizes the input, Parser turns tokens into a stream of parsing events, Composer assembles those events into a node graph, Constructor walks the node graph to build native Python objects, and Resolver decides implicit tag types (e.g. distinguishing a bare 42 as an int vs a string). Concrete loader classes such as SafeLoader, FullLoader, and Loader (in lib/yaml/loader.py) simply combine these mixins with different Constructor variants to control how much trust is placed in the input — SafeConstructor only ever builds plain dicts/lists/scalars, while Constructor/UnsafeConstructor can instantiate arbitrary Python objects from YAML tags, which is why yaml.load() requires an explicit Loader argument and safe_load() is the recommended default. The emitter side mirrors this with Emitter, Serializer, and Representer stages composed into Dumper/SafeDumper classes.

Tech Stack The library is pure Python at its core (lib/yaml/*.py, ~5,900 lines across scanner, parser, emitter, constructor, representer, and resolver modules) with an optional Cython extension (lib/_yaml/_yaml.pyx) that binds to the C libyaml library for the CSafeLoader/CDumper fast path. Packaging uses a custom PEP 517 build backend (packaging/) driven by setup.py and pyproject.toml, which probes for a system libyaml install and conditionally builds the Cython extension; when libyaml isn’t available, PyYAML falls back transparently to the pure-Python implementation.

Code Quality The tests/ directory includes both a modern pytest-based suite (test_dump_load.py, test_merge.py) and an extensive legacy suite (tests/legacy_tests/) covering structure, constructors, representers, resolvers, error handling, and round-trip canonical-YAML fixtures — a strong signal of correctness coverage for a spec-implementing library, though the codebase predates modern Python type hints and does not use static typing throughout. Security-sensitive code paths are explicit: BaseConstructor.check_state_key() blacklists dunder/state keys during deserialization to reduce (but not eliminate) the risk of yaml.load() on untrusted input, and the CHANGES file documents a long history of CVE-driven hardening (safe-by-default behavior was added specifically in response to arbitrary-code-execution reports).

API Design The public API is deliberately minimal and mirrors Python’s own pickle/json module conventions (load/dump, safe_load/safe_dump), which makes onboarding nearly instant for any Python developer. The main ergonomic sharp edge — needing to pick a Loader class and understanding the safe-vs-unsafe distinction — is well documented in the README and is the single most important thing new users must learn; beyond that, extension points (registering custom constructors/representers for new tags) are straightforward subclassing patterns.

Used by 90 apps in this directory

C++
75%
Apache 2.0

Timeplus Proton

Analytics · Data Engineering

2,273

Single C++ binary SQL engine for real-time stream processing, ETL, and analytics on Kafka, Redpanda, and ClickHouse with sub-millisecond latency.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
C++ 75%
Python 11%
Updated 2 weeks ago
C++
75%
Apache 2.0

Timeplus Proton

Analytics · Data Engineering

2,273

Single C++ binary SQL engine for real-time stream processing, ETL, and analytics on Kafka, Redpanda, and ClickHouse with sub-millisecond latency.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
C++ 75%
Python 11%
Updated 2 weeks ago
Python
73%
Apache 2.0

timesfm

AI Development · Analytics

34,750

A pretrained decoder-only foundation model by Google Research that delivers zero-shot time series forecasting with calibrated quantile prediction intervals — no training required.

View details
76
Repo Health
81
Technical
71
Dependency
Built with
Python 73%
HTML 14%
Jupyter Notebook 12%
Updated 1 months ago
Python
68%
AGPL 3.0

Tracecat

AI Agents · Automation · Security

3,860

Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.

View details
89
Repo Health
88
Technical
66
Dependency
Built with
Python 68%
TypeScript 30%
Updated 6 days ago
Go
94%
MIT

Traefik

Automation · Devops · Security

65,344

A cloud-native reverse proxy and load balancer that auto-configures itself from Docker, Kubernetes, and other orchestrators — zero manual routing required.

View details
93
Repo Health
85
Technical
64
Dependency
Built with
Go 94%
Updated 1 weeks ago
Python
73%
Apache 2.0

Unsloth

AI Assistants · AI Development

78,493

Run and fine-tune LLMs, diffusion, audio and embedding models on your own hardware, from a native desktop app, a browser UI, or a Python library.

View details
89
Repo Health
83
Technical
70
Dependency
Built with
Python 73%
TypeScript 22%
Updated 6 days ago
Python
96%
AGPL 3.0

VideoHighlighter

Video Editors

296

Local AI desktop tool that scores, explains, and cuts the moments that matter in raw footage — scene, motion, audio, object, and action detection, fully offline via Ollama and Whisper.

View details
83
Repo Health
84
Technical
71
Dependency
Built with
Python 96%
Updated 1 weeks ago
Rust
33%
Other

Windmill

Automation · Developer Tools

18,257

Turn scripts into webhooks, workflows, and auto-generated UIs — the fastest self-hostable workflow engine, 13x faster than Airflow.

View details
91
Repo Health
82
Technical
64
Dependency
Built with
Rust 33%
TypeScript 24%
Svelte 22%
Updated 6 days ago
Python
66%
Apache 2.0

WrenAI

AI Agents · Analytics · Data Engineering

17,958

Open-source GenBI engine that lets AI agents turn natural-language questions into governed SQL, charts, and shareable dashboards across 20+ data sources — no vendor lock-in, no black-box prompts.

View details
91
Repo Health
91
Technical
68
Dependency
Built with
Python 66%
Rust 31%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers