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 and YamlSequence implement the dict/list protocols (subscript, iteration, len, in, etc.) but are not dict/list subclasses. Call doc.to_python() (recursive) for a plain dict/list — needed for json.dumps, pydantic, msgspec, cattrs, and other libraries that type-check input strictly.

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.8.0.tar.gz (244.2 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.8.0-cp314-cp314-win_amd64.whl (550.7 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.8.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (672.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.8.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.3 MB view details)

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

yarutsk-0.8.0-cp313-cp313-win_amd64.whl (551.0 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.8.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (674.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.8.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.8.0-cp312-cp312-win_amd64.whl (551.2 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (675.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.8.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.8.0.tar.gz.

File metadata

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

File hashes

Hashes for yarutsk-0.8.0.tar.gz
Algorithm Hash digest
SHA256 358d37b0677d23088fa79d6f3edbe60df94c4be57f7b2618687f585f269d2c5b
MD5 1e8ae6312419962851e87ced00c0c48e
BLAKE2b-256 b9bc044541780a3c25493be403cff123d4ad840e36c8162d0da7842bb7527566

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.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.8.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: yarutsk-0.8.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 550.7 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.8.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 36f71d8e0914b978d644ebd32270354c223b815ea525b1717fa23b9bb1c25ebb
MD5 827c5769159819ea87a36f74d6c636ad
BLAKE2b-256 7cbad26a9946761689df6f575835856ee97ea479cd2bd8b442b8cf739dd07054

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.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.8.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for yarutsk-0.8.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4182499a13d8dfdeca90cf8e5aeda59ef97784163d09cb73efb99d43edd589e8
MD5 154a7e897fc4b3df882833ba06f72379
BLAKE2b-256 1f63c6a42c3e4ee2e7ae98b838ca174928507c006da8c8cb1ed20d773afaabd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.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.8.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.8.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 fd3163729d44ebb65fcada979e84c7d9fda10bf90ebaee97382620febb71f725
MD5 be0614008f3e7a1d839c7ec66a216738
BLAKE2b-256 3b2bc3eda1dcfd2c9128827a260a156842aec7bb471278f178abe13ce026046d

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.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.8.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: yarutsk-0.8.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 551.0 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.8.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c1c9fe4f7abc9c05ffa629f0d7d55f801ddde647c3201e6252b4ac84e4435d30
MD5 d1eb33f032d7b9e8e752e801cd66d1b4
BLAKE2b-256 2b81a06503ec5d512c4e0d4c25b5705338454adb075efb56ec6774e3923fdf7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.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.8.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for yarutsk-0.8.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 94040a0354fff3e0da58ca99f5cf936562cc113847ba8f295db59567c2056432
MD5 d63c51e0a7b873add714b6d4e43907d6
BLAKE2b-256 2c4807837ef281306e7b4257da2fb29ffe72191abcba9bb597cd8cc883627752

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.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.8.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.8.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 2e2f0bdd6c3e8afc50222fdacf2e0f63b7beb1d844b8082def580f4bc94eb68b
MD5 e05c1d0d45742602f678a51bbea956f5
BLAKE2b-256 8348cceb6289b19b86239cbfa06624ae06ba00562bf335ebda63969a1f47171e

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.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.8.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: yarutsk-0.8.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 551.2 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.8.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5b9717589b56217795a8be232d580cc8dc47269cef346e05d73c76b4216fd43e
MD5 0e377ab63e5da352cd7f02ecf748f3ad
BLAKE2b-256 40a88ad5ae22ed44e1b3400ac7fc90bc785f8b1c6b14930b26e46cd314202b56

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.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.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for yarutsk-0.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6131892f47fa7c94fdd671ed85e95595f24cebdd84fd3876ff40e5e8cf86b327
MD5 87e17afcc78b9e6228a36429e11b1f41
BLAKE2b-256 ae969c2cdf55a3f4a38b07d0c0d2c93713126465dfe945655084298ee63d590e

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.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.8.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.8.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 2ee69142866d23cd9a034516200e19359abcfb36bd65e2b7c31ecdce5128e14e
MD5 dfc07c2e5c9d6e1b700808cf4c5bbf2f
BLAKE2b-256 bf47207c09e64a43926efed681aa4fa800f397aafc12cddd2d1e7972d137051e

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.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