YAMLRocks vs fast-yaml
fast-yaml (the fastyaml-rs package) is a
Rust-backed YAML 1.2 parser built on the saphyr crate, with a PyYAML-style
safe_load/safe_dump API and built-in linting. It is a capable, fast reader,
and of the newer Rust parsers it gets the most right. But it is still a one-way
parser: it does not edit YAML, resolve includes, or validate against a schema,
and YAMLRocks is both more complete and faster.
Feature comparison
Section titled “Feature comparison”| Feature | fast-yaml | YAMLRocks |
|---|---|---|
| Comment-preserving round-trip | No | Yes (byte-for-byte) |
Native !include + writeback | No | Yes |
| JSON Schema validation | No | Yes (line-numbered) |
| Source line/column | No | Yes (annotated mode) |
| Custom tag handling | Unverified | Yes |
| Verified vs the YAML suite | Not stated | Yes, in full |
Merge keys (<<) | Yes | Yes |
| Anchors/aliases resolved | Yes | Yes |
| Multi-document streams | Yes | Yes |
| Implementation | Rust (saphyr) | Rust (own scanner/emitter) |
| Speed (parse / dump) | baseline | ~1.7x / ~1.7x faster |
A parser, or a toolkit
Section titled “A parser, or a toolkit”fast-yaml reads YAML into Python and lints it. YAMLRocks does that and the rest of what a real configuration workflow needs:
- Comment-preserving round-trip. Load with
OPT_ROUND_TRIP, change a value, and re-emit with comments, anchors, and formatting intact; an unmodified document comes back byte-for-byte. fast-yaml explicitly does not preserve comments, so it can read a file but not edit one. - Native
!includewith file-aware write-back across a split configuration. - JSON Schema validation with line-numbered errors.
- Annotated mode with the source line and column on every node.
- Custom tag handling, and safe-by-default loading.
See round-trip editing, includes, schema validation, and annotated mode.
Both are Rust extensions built on strict YAML 1.2. YAMLRocks is faster on both directions.
| Operation | fast-yaml | YAMLRocks | YAMLRocks is |
|---|---|---|---|
| Reading | ~2.9 ms | ~1.7 ms | ~1.7x faster |
| Writing | ~1.7 ms | ~1.0 ms | ~1.7x faster |
Correctness, verified rather than assumed
Section titled “Correctness, verified rather than assumed”fast-yaml is the most correct of the newer Rust parsers, it resolves merge keys,
where yaml-rs, ryaml, and py-yaml12 leave << as a literal key. That makes the
remaining difference the interesting one: YAMLRocks checks its parsing against the
entire official YAML test suite on every change (load, round-trip, and canonical
result), and fast-yaml still misreads a leading-zero integer:
import yamlrocks
# `0777` is a string in YAML 1.2 (the octal form is `0o777`), not the number 777.yamlrocks.loads(b"mode: 0777")# {'mode': '0777'}# fast-yaml returns {'mode': 777}.The point is not one scalar; it is that “verified against the whole suite” is a guarantee fast-yaml does not make, and the edges are where that shows.
Where fast-yaml is a reasonable pick
Section titled “Where fast-yaml is a reasonable pick”fast-yaml is a fast, dual-licensed (MIT/Apache-2.0) 1.2 parser with a familiar
safe_load/safe_dump surface and a handy built-in linter. If you want a quick,
drop-in-flavored reader for trusted YAML and never write edited files back, it is
a reasonable choice, and more faithful than its Rust peers.
When to choose YAMLRocks
Section titled “When to choose YAMLRocks”Choose YAMLRocks when YAML is something you edit, include, validate, and depend on: comment-preserving round-trip, native includes, schema validation, and source locations, on a parser that is verified correct against the full YAML test suite and is faster too.
See also
Section titled “See also”- YAMLRocks vs yaml-rs, vs ryaml, and vs py-yaml12: the other Rust-backed parsers.
- Performance: the benchmark methodology.