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.7.8.tar.gz (241.7 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.7.8-cp314-cp314-win_amd64.whl (549.9 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.7.8-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (668.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.7.8-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.7.8-cp313-cp313-win_amd64.whl (554.5 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.7.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (674.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.7.8-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.7.8-cp312-cp312-win_amd64.whl (555.0 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.7.8-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.7.8-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.7.8.tar.gz.

File metadata

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

File hashes

Hashes for yarutsk-0.7.8.tar.gz
Algorithm Hash digest
SHA256 98dc097308bcf5a372dcea3bc5bda4924edec5a77d3ce2f73e1eb961f4c0446a
MD5 aef89feba3e73f33c6bfca698bfbffac
BLAKE2b-256 bae0b05a289b07f8bbb72a58ee8dda5039f606a9c2afd05ad533ec772ae70495

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.8-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 549.9 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.7.8-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 568c726ce52015c3c7e4e210d797e6844dc4f17067c11c859fe04c21ef12c1aa
MD5 2397062adfe7d0e514d2f7960610469a
BLAKE2b-256 56fcbd297f8b2c35b2704f5f928f6c2be63b1ca99885c6a2ead693596bd9e742

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.8-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f8b5357d9f86459c601cea55cb2ad2c38563fff15bdc1a31392ae0248da0fb32
MD5 01af69a7f8f57ebd7a997ab5b127ca01
BLAKE2b-256 dbc25e54a2ced4e001916771821b4fdbcf7952b060228c0646648ba0c20ffffc

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.8-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.7.8-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for yarutsk-0.7.8-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 6f813b874d637218adeacd4d5f4d9cc9e7ee060710433e1b13959990e6efcf84
MD5 8daa7baf4117f1c76ef8cb57e4806485
BLAKE2b-256 5b8deb83eed431ca7e570f4735bd98e007e185967f6cc974f1e0e60ba8cdf28f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.8-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 554.5 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.7.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2660bf4717bc9de913fe506510d8950de526b89979fc0bdc3d431292d71f83ca
MD5 02e86d72ee15829db07f491c29202463
BLAKE2b-256 4b12a27c7438909c3b32af2e758e623b157a7dd174e3c20a16f37f0264efc767

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.8-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 107a5ec3ec7c873ef2b7288f534787ffabb2b6125370b570df81d1b6d9edaa30
MD5 f64fd8f667a3eef25212b6a3fa573647
BLAKE2b-256 50855a80ba79e8d9de492a3a63a456372ecbba2fe144f380eb908e9de9845f31

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.8-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.7.8-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for yarutsk-0.7.8-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 5f536d63fe624828aa13f56fa7661c390ce30ed46f9c782fe46a44c3ed3ba9e8
MD5 47a5073ddda2cbd80677ad88174b31b7
BLAKE2b-256 9b410a647a8af097d6fe0f76703b212bf19aef613fb143915b4d4f08fc922f15

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 555.0 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.7.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fddcef604e1b3792ad60e6051006a96954b34427948b6d4a77621320f8f52245
MD5 5f06d5752369b574f4f9a4b9c64310c3
BLAKE2b-256 0c053b2f3fe8403bd67b73b5d861a31f02eefbf5a94b224cfbbd4dddf229576b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 973a8f8c0ed52aefaa87439bf489f500779ea4bb4d8b82a0bafc475803c5abf2
MD5 2d885a9909bca53e6869afe08f15e180
BLAKE2b-256 35dbe90a35942bd76694f1b16685cd5bed0b2e379ca255e64d2e04a4d22bf541

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.8-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.7.8-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for yarutsk-0.7.8-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 b234c84614f02a96eae72fc717e2bd74b3450183b8ff4bd63dd6029b9e099f18
MD5 acf9ee1782e06e65339dc08cdf82e57d
BLAKE2b-256 145b6d444ca503ad66a52902f1e17eef7aac1f669954d5f8c9e9b72b0e2059cd

See more details on using hashes here.

Provenance

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