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
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.1.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.1-cp314-cp314-win_amd64.whl (550.8 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.8.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (672.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.8.1-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.1-cp313-cp313-win_amd64.whl (550.9 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.8.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (674.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.8.1-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.1-cp312-cp312-win_amd64.whl (551.1 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.8.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: yarutsk-0.8.1.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.1.tar.gz
Algorithm Hash digest
SHA256 60cdf58fe1e9d4b3bee0582260a459724a2bb230461f421aacffbcd4069258d5
MD5 92ae1e2c6f4cf23f8ba459ff1ab0b024
BLAKE2b-256 84844acd02a5735ade678910b9d16b5d6538503255055531ec59ba108b7c054d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.8.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 550.8 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.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 1c6b60c36328c3ae241900ee2916ae1ac5b24eda02f93816e17b541f8a03ee8e
MD5 1eb01e8f29c97f7ddd4440622280e92c
BLAKE2b-256 2fa8e8029685400657389c0e0acc1756cf96d71274f70942e36ff54a4b6ebc36

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.8.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ce910b2ba4256b7967bcb4cc29f1fa6877502f1911efd0352152efef606887b
MD5 97e8b0a6a37b6d99f9759a3cbbb72c54
BLAKE2b-256 7ec43fe58cc43072520109c49711ce2a82546dd53eeda48efc2e2b11f736ae9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.1-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.1-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.1-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 a90054ea8e64b41235a2e63fe0f268826fb041c858e8ec5bd7aa00e93ee83254
MD5 831f231ab3697da9f21aefeb42d1b581
BLAKE2b-256 f939f7c45e2299052ecdd10f41cd09fb846a318bd1f85d30d58fd40392c2e603

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.8.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 550.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.8.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5a22496352a3d6b09c455450ceb4bb21903f78266f05656b0c61dd3b44429a5f
MD5 5496faec6d9346b92fcddd1b2823b347
BLAKE2b-256 082c0bed567b5510f608f04e1f02c45a9bf410123c9627ec3e3a268e9d7f9ab2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.8.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 457c3d3214bef69f8ee8fe7ac1133448684739c4063800a29e04bdd44c370e62
MD5 6fc15709b0de3236d98f546647090ae5
BLAKE2b-256 9623af46f48973d373f8b681aff004453a014b7437061cb55e46538fa976ca66

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.1-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.1-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.1-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 66842a903c6714d9a599379c3f2846fdb784917f7d2bb405fe8367e3d96e35f7
MD5 478f38217154d3926ccd5026a89acf70
BLAKE2b-256 bab747ac9f380b08b2c4f88bfacdcc6a0c880cd37129487c8fdc3b9b5aa00c5b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.8.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 551.1 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bd383d02fee0babb8a524038a2533c432f9b90732aeeef7111ea6bf77ac5698b
MD5 cc95f117cb15aa2dad3306221207d998
BLAKE2b-256 fa358d449ee3b5737ea4e1b8cb28d6c0e00d6df906520a51ba195e79ad950c73

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.8.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e16af2936b55f5f3e1ddcdd2825ea5d2c2e4bfcbb8523243bbdcca8da6d0410
MD5 a74ae717ffea89b7549c427f10252390
BLAKE2b-256 872092249180587293ce993ad56c4078edb6a549835abf924201763959ded534

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.1-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.1-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.1-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 133f4dcd5b1ed6819481f9a2145733f23cfe57c7eaf89fc6194c8e7fbe22b967
MD5 0bdecae5152218459d5ac92c3308aaf0
BLAKE2b-256 1ef7df158be346b0b551727cdfa22363b6906f545b1c80f0105dfb44c7570306

See more details on using hashes here.

Provenance

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