Repository navigation
ryaml 0.6.0
Overview
ryaml 0.6.0 is a major update: ryaml now works as a drop-in replacement for PyYAML's fast C-based CSafeLoader and CSafeDumper, and it is faster than both them and the previous ryaml versions. It also lets you customize how your own types are written out to YAML (#67), and ships prebuilt wheels for many more platforms, including musl-based Linux distributions like Alpine, as well as Android, iOS, Pyodide (Python in the browser), more Linux CPU architectures, 32-bit Windows, and free-threaded Python (#65, #76). Python 3.15 is now supported, and Python 3.10 is no longer supported as it has reached end of life (#75).
PyYAML drop-in compatibility
ryaml's internals have been re-written to use a libyaml-compatible Rust library to ensure that ryaml is drop-in compatible with PyYAML. If PyYAML is installed, except yaml.YAMLError catches ryaml's errors too. ryaml has been thoroughly tested against PyYAML using differential fuzzing and testing against YAML files from The Stack v3. Any difference found between ryaml and PyYAML's CSafeLoader and CSafeDumper that is not documented is a bug.
Performance
Compared with ryaml 0.5.1, loading is 1.7–2.8x faster and dumping is 1.5–3.3x faster. Compared with PyYAML's C-based classes, ryaml 0.6.0 loads 3.3–7x faster than CSafeLoader and dumps 3.5–16.5x faster than CSafeDumper across ryaml's benchmarks.
Breaking changes
Because ryaml now closely matches PyYAML, some behavior has changed since 0.5.1. Unquoted values are interpreted the way PyYAML does: yes loads as True, 010 as 8, and 2001-01-01 as a datetime.date, while 1e3 stays a string. Dumped YAML matches PyYAML's output: non-ASCII characters are escaped (é is written as "\xE9"), multi-line strings are quoted, long lines wrap at 80 characters, and an object that appears more than once is written once and referenced with an anchor, so update any tests that compare against saved YAML output. Errors use PyYAML's exception classes and messages, loads raises ComposerError if the input contains more than one document (use loads_all for that), and loads_all("") now returns [] instead of None (#77). Python 3.11 or newer is required. If there is no prebuilt wheel for your platform and pip builds ryaml from source, you need Rust 1.89 or newer installed.
Hopefully, future versions will contain significantly fewer breaking changes as they should only need to fix compatibility bugs.