RapidYAML (ryml) is a Python wrapper for a fast C++ library designed to parse and emit YAML. It focuses on performance by exposing a low-level, index-based C++ API that operates with node indices and string views, rather than automatically building Python dict/list structures. The current version is 0.11.1, and it maintains an active release cadence.
pip install rapidyamlVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates parsing a YAML byte string and traversing the resulting tree using RapidYAML's low-level, index-based API. It shows how to find child nodes by key and iterate through sequence items, decoding byte strings to Python strings for output.
Be prepared to iterate through the tree structure manually using methods like `root_id()`, `first_child()`, `next_sibling()`, `key()`, `val()`, and `is_map()`, `is_seq()`. Decode byte strings (e.g., `.decode('utf-8')`) when Python strings are needed.Ensure that any YAML string passed to `ryml.parse()` is first encoded to bytes, typically `your_string.encode('utf-8')`.If you need an empty tree that behaves like older versions (i.e., `root_id()` creates the root), ensure you initialize it with `tree = ryml.Tree()` if that is the intended behavior in the Python wrapper. If you explicitly need an empty tree, initialize with `ryml.Tree(0)`.
When dealing with JSON-like input, ensure it conforms to standard YAML or remove explicit quotes around keys if parsing with `ryml.parse()`.
Encode the input string to bytes before parsing, e.g., `ryml.parse(my_string.encode('utf-8'))`.Always check the return value of tree traversal methods (e.g., `find_child`, `first_child`, `next_sibling`) against `ryml.NONE` before attempting to use the returned ID.
Manually iterate the `ryml.Tree` object using its index-based API to construct Python dictionaries and lists if required. For example, check `tree.is_map(node_id)` or `tree.is_seq(node_id)` to determine the YAML type.
No dependency data recorded yet.