Skip to main content

A YAML round-trip library that preserves comments and insertion order

Project description

yarutsk

PyPI Python 3.12+ License: MIT

⚠ AI-authored. This library — design, implementation, tests, and documentation — was written by Claude Code (Anthropic) under human direction.

A Python YAML library that round-trips documents while preserving comments, insertion order, scalar styles, tags, anchors and aliases, blank lines, and explicit document markers.

Full documentation: https://theyugin.github.io/yarutsk/

Quick start

pip install yarutsk
import io
import yarutsk

doc = yarutsk.load(io.StringIO("""
# database config
host: localhost  # primary
port: 5432
"""))

doc["port"] = 5433

out = io.StringIO()
yarutsk.dump(doc, out)
print(out.getvalue())
# # database config
# host: localhost  # primary
# port: 5433

YamlMapping subclasses dict and YamlSequence subclasses list, so they work everywhere a dict or list is expected — isinstance(doc, dict), json.dumps(doc), and any library accepting plain mappings or sequences.

Python 3.12+ required. Pre-built wheels for Linux / macOS / Windows on x86_64 and aarch64.

What's preserved

  • Scalar styles — plain, 'single', "double", literal |, folded >
  • Non-canonical scalarsyes/no/on/off, ~, 0xFF, 0o77 reproduced as written
  • YAML tags!!str, !!binary, !!timestamp, and any custom tag
  • Anchors and aliases&name / *name round-trip intact
  • Blank lines between entries and explicit document markers (---, ...)

Comparison

Feature yarutsk ruamel.yaml PyYAML
Comments preserved Yes Yes No
Scalar styles preserved Yes Partial No
Insertion order preserved Yes Yes No
Blank lines preserved Yes Partial No
Tags preserved Yes Yes No
Anchors/aliases preserved Yes Yes No
dict / list subclasses Yes No No
Rust speed Yes No No

yarutsk focuses on round-trip fidelity: edit a config file and emit it back without touching the formatting. ruamel.yaml offers similar fidelity in pure Python. PyYAML is faster for load-only workloads where output formatting doesn't matter.

Documentation

Everything — the full API, type conversions, Schema and library integrations (pydantic / msgspec / cattrs), error handling, thread safety, and limitations — lives at https://theyugin.github.io/yarutsk/.

Direct links:

Benchmarks

Compare load, dump, and round-trip performance against PyYAML and ruamel.yaml:

make bench

License

MIT. The scanner and parser are vendored from yaml-rust2 (also MIT) with one targeted modification: the comment-skipping loop now emits Comment tokens instead of discarding them.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yarutsk-0.5.0.tar.gz (203.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

yarutsk-0.5.0-cp314-cp314-win_amd64.whl (538.1 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.5.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (658.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.5.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.2 MB view details)

Uploaded CPython 3.14macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

yarutsk-0.5.0-cp313-cp313-win_amd64.whl (542.9 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (664.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.5.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.3 MB view details)

Uploaded CPython 3.13macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

yarutsk-0.5.0-cp312-cp312-win_amd64.whl (543.5 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (665.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.5.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.3 MB view details)

Uploaded CPython 3.12macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file yarutsk-0.5.0.tar.gz.

File metadata

  • Download URL: yarutsk-0.5.0.tar.gz
  • Upload date:
  • Size: 203.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yarutsk-0.5.0.tar.gz
Algorithm Hash digest
SHA256 20f0ab688ab5936054c7070dcb9873bb1561de1c5ce394db41d96c3351eae64c
MD5 32fe4234c6fa2d5a8cbdf8bba8608998
BLAKE2b-256 80cff93e1f0ee481ab4b7a2c6576cf327e438c73c550565cc0d9a9b94c26cc86

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.0.tar.gz:

Publisher: ci.yml on theyugin/yarutsk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yarutsk-0.5.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: yarutsk-0.5.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 538.1 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yarutsk-0.5.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 c0b528e4f7abe18a307e354eb2f5e4d927b1a8d1d484878534d655d3f79b3001
MD5 f87f59429b220ba21bf89159fe9207d9
BLAKE2b-256 25c427077f670bef4e4f2162c6da40492f6f0b20bfe2fd19173ad43e04bdc5cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.0-cp314-cp314-win_amd64.whl:

Publisher: ci.yml on theyugin/yarutsk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yarutsk-0.5.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for yarutsk-0.5.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 faa8a89d2630851c2b0c68aa75d9b22089e821b48626ab8a4829459b3b94492f
MD5 ec165400f089195cb877c119a13f624f
BLAKE2b-256 1782bbcfa96abebcad74d1bcca94c7459c8c512dca96acf24aa8fbaee96897fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on theyugin/yarutsk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yarutsk-0.5.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for yarutsk-0.5.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 5dd27c196b50dacd75ddcbca4f82a0c8b9fdf76c2b24e76ab1bee22408b24182
MD5 eb2e37213458acf656679bfac19983f8
BLAKE2b-256 31edb8e6f3ba7e041a645193c71c6c1083999e0c6d3978f735a7b552d2c2a2a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: ci.yml on theyugin/yarutsk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yarutsk-0.5.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: yarutsk-0.5.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 542.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yarutsk-0.5.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 db8672946821543944440fb9c0d6e18ce8ee20ed07a7e51a84c34870a2a4d06a
MD5 b066f52d2f92c32864e3e7e3faeeda6f
BLAKE2b-256 78f36edcb045292941c56e4faa0c154fb685af180116a79ae2e6414c5de147a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.0-cp313-cp313-win_amd64.whl:

Publisher: ci.yml on theyugin/yarutsk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yarutsk-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for yarutsk-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5c2508cc23b0004882f39e7208f980f631f9133f89d74399849269d336c9afdd
MD5 bdc0878b4a86a984f8962aa9389862da
BLAKE2b-256 9c62b253c08692585d89a5856245ec19010ce41482fa55b711745cd5d5dc1702

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on theyugin/yarutsk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yarutsk-0.5.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for yarutsk-0.5.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 84cb09589c75a2739330cdcdd8cb7c8aa72c6387a7da8bfff7098c40774de538
MD5 44b73a0bfa9030a3ac9d13275b17ed72
BLAKE2b-256 38f6e5c751e9cb9c113b8cfc4f05ef768ba1c3c4dfcca86172e942fa51a4cbed

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: ci.yml on theyugin/yarutsk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yarutsk-0.5.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: yarutsk-0.5.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 543.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yarutsk-0.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ac0a24a4914679c026294a675a18c71a6c688c066480aeadb91a283e02750a3a
MD5 d9f36f155f70e85850e429a660fa1360
BLAKE2b-256 13339961809868109df6e22d8558d69ce2ea79581a1ef8d336c7140d1f504497

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.0-cp312-cp312-win_amd64.whl:

Publisher: ci.yml on theyugin/yarutsk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yarutsk-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for yarutsk-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d70efd4e4e9bb13db21f482e30f1e86eebb2fd584ebffc0493a318a562227fb
MD5 2d5223e58ad72461be81576b9e00692d
BLAKE2b-256 4944ec11a955eb0d5c45665762eca00b58e316331964cbdfc23e71f14a23d9fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: ci.yml on theyugin/yarutsk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file yarutsk-0.5.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for yarutsk-0.5.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 2fad3b2cc8acee12592452557787b303f4a7c860651cf21abf586b1b0b6c1ef7
MD5 ba8ae420d5178f5e4577645e1778f840
BLAKE2b-256 744867861b358d8d518aea841f1c3b616250783bd0beb12c93182f6d57feaf96

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: ci.yml on theyugin/yarutsk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page