Skip to content

YAMLRocks vs ryaml

ryaml is a Rust-backed YAML reader with a deliberately small, json-module-style API. It is a fine way to turn a trusted file into Python data, but that is all it does, and it is alpha software. YAMLRocks is the full configuration toolkit, comment-preserving round-trip, native includes, schema validation, source locations, and verified-correct parsing, and it is several times faster.

FeatureryamlYAMLRocks
Comment-preserving round-tripNoYes (byte-for-byte)
Native !include + writebackNoYes
JSON Schema validationNoYes (line-numbered)
Source line/columnNoYes (annotated mode)
Custom tag handlingNoYes
Verified vs the YAML suiteNot statedYes, in full
Merge keys (<<)NoYes
Anchors/aliases resolvedYesYes
ImplementationRust (libyaml-safer)Rust (own scanner/emitter)
Speed (parse / dump)baseline~2.8x / ~3.4x faster
Maturity0.5.x, alphaBattle-tested corpus

ryaml reads YAML into Python and stops. YAMLRocks does that and the rest of what a real configuration workflow needs:

  • Comment-preserving round-trip. Edit a value and re-emit with comments, anchors, and layout intact; an unmodified document is byte-for-byte identical. ryaml drops comments and formatting, so it can read a file but not edit one.
  • Native !include with 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 that never builds arbitrary Python objects.

See round-trip editing, includes, schema validation, and annotated mode.

Both are Rust extensions, so this is Rust vs Rust. YAMLRocks is well ahead on both.

YAMLRocks vs ryaml on reading and writing: YAMLRocks is several times faster on both loads and dumps.

OperationryamlYAMLRocksYAMLRocks is
Reading~4.7 ms~1.7 ms~2.8x faster
Writing~3.4 ms~1.0 ms~3.4x faster

YAMLRocks’s parsing is checked against the entire official YAML test suite on every change. ryaml publishes no such guarantee, describes itself as YAML 1.1 yet resolves no and 0o17 the 1.2 way, and does not implement merge keys:

import yamlrocks
# Merge keys: YAMLRocks folds the base in; ryaml leaves `<<` as a literal key.
yamlrocks.loads(b"base: &b\n timeout: 30\nsvc:\n <<: *b\n name: api\n")
# {'base': {'timeout': 30}, 'svc': {'timeout': 30, 'name': 'api'}}

The point is not one missing feature; it is that YAMLRocks commits to a schema and proves it, so you always know which reading you get.

ryaml is a small, MIT-licensed, json-style reader. For quickly loading trusted YAML 1.2 data with no writing and no merge keys, it is easy to reach for. It is alpha (0.5.x) with a thin surface by design.

Choose YAMLRocks when YAML is something you edit, validate, and depend on: round-trip with comments, includes, schema validation, and source locations, on a verified-correct parser that is also several times faster.