{"id":51326806,"url":"https://github.com/frenck/yamlrocks","last_synced_at":"2026-07-01T19:02:26.275Z","repository":{"id":363583232,"uuid":"1261327662","full_name":"frenck/YAMLRocks","owner":"frenck","description":"Rock-solid YAML for Python, written in Rust.","archived":false,"fork":false,"pushed_at":"2026-06-25T00:36:56.000Z","size":1131,"stargazers_count":69,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-06-25T02:05:14.909Z","etag":null,"topics":["python","python-library","python3","rust","rustlang","yaml","yaml-parser","yaml-schema"],"latest_commit_sha":null,"homepage":"https://yaml.rocks","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frenck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":"frenck","patreon":"frenck","custom":"https://frenck.dev/donate/"}},"created_at":"2026-06-06T14:39:09.000Z","updated_at":"2026-06-25T00:36:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/frenck/YAMLRocks","commit_stats":null,"previous_names":["frenck/yamlrocks"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/frenck/YAMLRocks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frenck%2FYAMLRocks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frenck%2FYAMLRocks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frenck%2FYAMLRocks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frenck%2FYAMLRocks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frenck","download_url":"https://codeload.github.com/frenck/YAMLRocks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frenck%2FYAMLRocks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35019037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","python-library","python3","rust","rustlang","yaml","yaml-parser","yaml-schema"],"created_at":"2026-07-01T19:02:25.075Z","updated_at":"2026-07-01T19:02:26.262Z","avatar_url":"https://github.com/frenck.png","language":"Rust","funding_links":["https://github.com/sponsors/frenck","https://patreon.com/frenck","https://frenck.dev/donate/"],"categories":[],"sub_categories":[],"readme":"# 🪨 YAMLRocks\n\n[![GitHub Release][releases-shield]][releases]\n[![Python Versions][python-versions-shield]][pypi]\n![Project Stage][project-stage-shield]\n![Project Maintenance][maintenance-shield]\n[![License][license-shield]](LICENSE)\n\n[![Build Status][build-shield]][build]\n[![Code Coverage][codecov-shield]][codecov]\n[![CodSpeed][codspeed-shield]][codspeed]\n[![OpenSSF Scorecard][scorecard-shield]][scorecard]\n[![Open in Dev Containers][devcontainer-shield]][devcontainer]\n\nRock-solid YAML for Python, written in Rust.\n\n## About\n\nYAMLRocks is the rock-solid YAML library for Python: a Rust-backed extension\nthat parses and emits YAML fast, follows the YAML 1.2 specification (with a\nYAML 1.1 compatibility mode), and, unlike PyYAML, round-trips documents while\npreserving comments, anchors, and formatting.\n\nRock-solid means three things: correct, secure by default, and fast, with a\nRust core doing the heavy lifting. (The R in Rock is for Rust.)\n\nThe Python YAML ecosystem has long forced a trade-off. YAMLRocks refuses it:\n\n| Library       |      Fast       |   YAML 1.2   | Comments / round-trip | Native includes |\n| ------------- | :-------------: | :----------: | :-------------------: | :-------------: |\n| PyYAML        |  with C loader  | ✗ (1.1 only) |           ✗           |        ✗        |\n| ruamel.yaml   | ✗ (pure Python) |      ✓       |           ✓           |        ✗        |\n| **YAMLRocks** |    ✓ (Rust)     |      ✓       |           ✓           |        ✓        |\n\nIt is also fast. Release-build benchmarks (`python bench/bench.py`) show how\nmany times faster YAMLRocks is:\n\n| Operation                                    | vs PyYAML (C loader) |   vs ruamel.yaml |\n| -------------------------------------------- | -------------------: | ---------------: |\n| Parse (`loads`)                              |        ~5-10x faster |  ~85-135x faster |\n| Serialize (`dumps`)                          |       ~15-19x faster | ~155-210x faster |\n| Split config (`!include`, hundreds of files) |          ~18x faster |              n/a |\n\nIt is safe against the common YAML attack classes, free-threaded (nogil) ready,\nand ships with JSON Schema validation, a PyYAML-compatible shim, rich standard-library\ntype support, and the `!secret` and `!env_var` config tags.\n\nYAMLRocks is also tested against a reproducible real-world corpus covering Home\nAssistant, ESPHome, Ansible, Kubernetes, Docker Compose, GitHub Actions,\nCloudFormation, GitOps, Helm, OpenAPI, dbt, CircleCI, Serverless, and Tekton.\nEach standalone YAML file must parse and round-trip byte-for-byte; selected Home\nAssistant configs are additionally tested through their full `!include` graph.\nSee [real-world verification][realworld-verification] for the current corpus and\nscope.\n\nYAMLRocks is pre-1.0 software. The core promises are already explicit: safe\nloading by default, YAML 1.2 semantics, reproducible real-world verification,\nand byte-for-byte round-trip for unmodified documents. Some advanced APIs may\nstill change before 1.0 while the project gathers production feedback. See the\n[stability and roadmap][stability-roadmap] page for the 1.0 contract.\n\n## Installation\n\n```bash\npip install yamlrocks\n```\n\nBuilding from source requires a [Rust toolchain][rustup]; see [Setting up\ndevelopment environment](#setting-up-development-environment) below for the\nuv-based build.\n\n## Usage\n\nThe API stays small: `loads` returns native Python objects and `dumps`\nreturns `bytes`.\n\n```python\nimport yamlrocks\n\n# Parse YAML into native Python objects\ndata = yamlrocks.loads(b\"key: value\\nlist:\\n  - 1\\n  - 2\")\n# {'key': 'value', 'list': [1, 2]}\n\n# Serialize back to YAML bytes (dumps() returns bytes)\nyamlrocks.dumps(data)\n# b'key: value\\nlist:\\n  - 1\\n  - 2\\n'\n\n# Multiple documents\nyamlrocks.loads_all(b\"---\\na: 1\\n---\\nb: 2\")\n# [{'a': 1}, {'b': 2}]\n\n# Load and dump files directly\nconfig = yamlrocks.load(\"config.yaml\")\nyamlrocks.dump(config, \"config.yaml\")\n```\n\n### YAML 1.1 compatibility\n\nYAML 1.2 is the default, so `yes`/`no`/`on`/`off` are plain strings. Opt into the\n1.1 schema when you need its booleans and octals:\n\n```python\nyamlrocks.loads(b\"enabled: yes\")                              # {'enabled': 'yes'}\nyamlrocks.loads(b\"enabled: yes\", option=yamlrocks.OPT_YAML_1_1)  # {'enabled': True}\n```\n\n`OPT_UPGRADE_1_1` reads 1.1 and always emits canonical 1.2, so a project can\nease off the legacy spellings without a manual conversion step.\n\n### Structure-preserving round-trip\n\n```python\ndoc = yamlrocks.loads(content, option=yamlrocks.OPT_ROUND_TRIP)\n\ndoc[\"server\"][\"host\"] = \"example.com\"   # deep edits write through to the AST\nprint(doc.to_yaml().decode())           # comments and formatting preserved\n```\n\nAn unmodified document re-emits byte-for-byte identical; only the nodes you touch\nare rewritten.\n\n### Native includes (read and write back)\n\n```python\ndoc = yamlrocks.loads(\n    content,\n    option=yamlrocks.OPT_ROUND_TRIP | yamlrocks.OPT_INCLUDES,\n    include_dir=\"/config\",\n)\n\ndoc[\"automation\"][0][\"trigger\"] = \"state\"   # edit a value from an included file\n\nyamlrocks.dump_includes(doc, include_dir=\"/config\")\n# Only the modified included file is rewritten; the root config is untouched.\n```\n\nSupported tags: `!include`, `!include_dir_named`, `!include_dir_list`,\n`!include_dir_merge_named`, `!include_dir_merge_list`.\n\n### Annotated mode (source-location tracking)\n\n```python\ndata = yamlrocks.loads(content, option=yamlrocks.OPT_ANNOTATED)\ndata.__line__              # 1\ndata[\"server\"].__line__    # 3\n```\n\n`YAMLRocksAnnotatedDict`/`YAMLRocksAnnotatedList`/`YAMLRocksAnnotatedStr` subclass `dict`/`list`/`str`, so\nthey behave exactly like the built-ins while carrying `__line__`, `__column__`,\nand `__file__`, compatible with Home Assistant's annotated YAML.\n\n### Option flags\n\nOptions compose with `|`, the integer bit-flag pattern:\n\n| Flag                                      | Effect                                                          |\n| ----------------------------------------- | --------------------------------------------------------------- |\n| `OPT_YAML_1_1`                            | YAML 1.1 schema (`yes`/`no` booleans, octals, etc.)             |\n| `OPT_UPGRADE_1_1`                         | Read 1.1, always emit canonical 1.2                             |\n| `OPT_ROUND_TRIP`                          | Return a `YAMLRocksDocument` preserving comments and formatting |\n| `OPT_ANNOTATED`                           | Return subclasses with source locations                         |\n| `OPT_INCLUDES`                            | Resolve `!include` tags (needs `include_dir`)                   |\n| `OPT_DUPLICATE_KEYS_ERROR`                | Reject a repeated mapping key                                   |\n| `OPT_INDENT_2` / `OPT_INDENT_4`           | Indentation width for `dumps`                                   |\n| `OPT_SORT_KEYS`                           | Sort mapping keys when dumping                                  |\n| `OPT_FLOW_STYLE`                          | Emit flow style (`{}`/`[]`)                                     |\n| `OPT_EXPLICIT_START` / `OPT_EXPLICIT_END` | Emit `---` / `...` markers                                      |\n\nSee the [documentation][docs] for the full option set, including the standard-library\ntype and datetime flags.\n\n## Documentation\n\nFull documentation lives at **[yaml.rocks][docs]**: getting-started guides,\nrecipes (Home Assistant, config editors), the complete API reference, security\nnotes, and head-to-head comparisons with PyYAML and ruamel.yaml.\n\n## Changelog \u0026 Releases\n\nThis repository keeps a change log using [GitHub's releases][releases]\nfunctionality. The format of the log is based on\n[Keep a Changelog][keepchangelog].\n\nReleases are based on [Semantic Versioning][semver], and use the format\nof `MAJOR.MINOR.PATCH`. In a nutshell, the version will be incremented\nbased on the following:\n\n- `MAJOR`: Incompatible or major changes.\n- `MINOR`: Backwards-compatible new features and enhancements.\n- `PATCH`: Backwards-compatible bugfixes and package updates.\n\n## Contributing\n\nThis is an active open-source project. We are always open to people who want to\nuse the code or contribute to it.\n\nWe've set up a separate document for our\n[contribution guidelines](CONTRIBUTING.md).\n\nUsing AI tools to help is fine, but you must review and understand everything you\nsubmit. Please read our [AI Policy](AI_POLICY.md) first; autonomous agents are\nnot allowed, and unreviewed AI output will be closed.\n\nThank you for being involved! :heart_eyes:\n\n## Setting up development environment\n\nThe easiest way to start is by opening a CodeSpace here on GitHub, or by using\nthe [Dev Container][devcontainer] feature of Visual Studio Code.\n\n[![Open in Dev Containers][devcontainer-shield]][devcontainer]\n\nYAMLRocks is a Rust extension built with [maturin] and managed with [uv], which\nhandles the Python version, the virtual environment, and every dependency from\n`pyproject.toml`. You need:\n\n- A [Rust toolchain][rustup]\n- [uv] (it installs a suitable Python 3.12+ for you)\n- Node.js 22+ (only for the documentation site and some lint hooks)\n\nTo set up the environment and build the extension:\n\n```bash\nuv sync                  # create the venv and install all dev dependencies\nuv run maturin develop   # build and install the extension (rerun after Rust changes)\n```\n\nAs this repository uses the [prek][prek] framework, all changes are linted and\ntested with each commit. You can run all checks manually:\n\n```bash\nprek run --all-files\n```\n\nTo run just the tests (always under a memory guard during development):\n\n```bash\ntimeout 120 bash -c 'ulimit -v 3000000; uv run pytest'\n```\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for the full workflow, including the\n`just` task runner and how to fetch the optional test-data submodules.\n\n## Authors \u0026 contributors\n\nThe original setup of this repository is by [Franck Nijhof][frenck].\n\nFor a full list of all authors and contributors,\ncheck [the contributor's page][contributors].\n\n## License\n\nMIT License\n\nCopyright (c) 2026 Franck Nijhof\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n[build-shield]: https://github.com/frenck/yamlrocks/actions/workflows/tests.yaml/badge.svg\n[build]: https://github.com/frenck/yamlrocks/actions/workflows/tests.yaml\n[codecov-shield]: https://codecov.io/gh/frenck/YAMLRocks/branch/main/graph/badge.svg\n[codecov]: https://codecov.io/gh/frenck/YAMLRocks\n[codspeed-shield]: https://img.shields.io/endpoint?url=https://codspeed.io/badge.json\n[codspeed]: https://app.codspeed.io/frenck/YAMLRocks?utm_source=badge\n[contributors]: https://github.com/frenck/yamlrocks/graphs/contributors\n[devcontainer-shield]: https://img.shields.io/static/v1?label=Dev%20Containers\u0026message=Open\u0026color=blue\u0026logo=visualstudiocode\n[devcontainer]: https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/frenck/yamlrocks\n[docs]: https://yaml.rocks\n[frenck]: https://github.com/frenck\n[keepchangelog]: http://keepachangelog.com/en/1.0.0/\n[license-shield]: https://img.shields.io/github/license/frenck/yamlrocks.svg\n[maintenance-shield]: https://img.shields.io/maintenance/yes/2026.svg\n[maturin]: https://www.maturin.rs/\n[prek]: https://prek.j178.dev\n[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg\n[pypi]: https://pypi.org/project/yamlrocks/\n[python-versions-shield]: https://img.shields.io/badge/python-3.12_%7C_3.13_%7C_3.14_%7C_3.15-blue?logo=python\u0026logoColor=white\n[realworld-verification]: https://yaml.rocks/verification/real-world-corpus/\n[releases-shield]: https://img.shields.io/github/release/frenck/yamlrocks.svg\n[releases]: https://github.com/frenck/yamlrocks/releases\n[rustup]: https://rustup.rs/\n[scorecard-shield]: https://api.scorecard.dev/projects/github.com/frenck/YAMLRocks/badge\n[scorecard]: https://scorecard.dev/viewer/?uri=github.com/frenck/YAMLRocks\n[semver]: http://semver.org/spec/v2.0.0.html\n[stability-roadmap]: https://yaml.rocks/stability-roadmap/\n[uv]: https://docs.astral.sh/uv/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrenck%2Fyamlrocks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrenck%2Fyamlrocks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrenck%2Fyamlrocks/lists"}