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.6.tar.gz (237.8 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.6-cp314-cp314-win_amd64.whl (553.6 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.7.6-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (674.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.7.6-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.6-cp313-cp313-win_amd64.whl (556.4 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.7.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (680.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.7.6-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.6-cp312-cp312-win_amd64.whl (557.0 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.7.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (681.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.7.6-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.6.tar.gz.

File metadata

  • Download URL: yarutsk-0.7.6.tar.gz
  • Upload date:
  • Size: 237.8 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.6.tar.gz
Algorithm Hash digest
SHA256 4bfd1a1031c3ab4f15cb493e981f8ede6a5d1637b34bd4930a1da48d91b42d3a
MD5 b4038d4a76289710d2876cfc26ff26ed
BLAKE2b-256 575bdcb83a8b7a17d914f53c9d43ece4a8b82895528a4ca3e3c1302454719847

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.6-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 553.6 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.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 982f0ac0de0ed9366137555046ac3637e6cb6d9f6741cd9949caa678159683ad
MD5 9c480c3b5d03641b7f350ae390dbde98
BLAKE2b-256 5d20d4180aaf3c35f3616185ee30ddf2eac1ebb9251ca42c69f7d8c31ac31b6e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.6-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 09583ab9edae5743ea34d4172567d32240f24c98f33de47ece65351df666acd7
MD5 ac35372537ece6c9d8ee0a923a12add3
BLAKE2b-256 541695797a87b86a0d7dc85dac53d2e2be7ef4579a4865c34124adcd0c7301f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.6-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.6-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.6-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 880ff45136a1c910fd00a40740bf347f3598dc802a73006f4d021e46ce4f0176
MD5 6b8321eaa98868b575df416f2656a52f
BLAKE2b-256 fb3382917e68b7e473a52d956eb4c288530a87b0147c8d0f0406f43f4ed21fca

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 556.4 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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ddd45706db39b7b3c89c1af28c7f4b8440fba4cb5c7360dcd40981ad238162c4
MD5 fe1a9a370ed11f310b79ff0631b38595
BLAKE2b-256 36c007e6a5a5bc0c95c888e7edb8c054f804b85b814cb2bcec52b6de4bf74d01

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a805812c98a61e7bfd28f94f31a634ae9f8629a4277b0a2bbda99f2eaebc2c0
MD5 7f8a076f85291b5b458d51c6c1079db5
BLAKE2b-256 15d940bf931b7d0513fdbedfcfe5b981cc46f5625aab7ca38e3a690afc43be5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.6-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.6-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.6-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 3f33663482097f345a0eeabdd6214cba142aee4620e2e53b0a525c68c20e961a
MD5 3f19f0b140b47902074ab9db172a058c
BLAKE2b-256 79557f8531bd6e3ffa7d9a0e66d43715179b6fc0583337552c7ff1b76be8ecd6

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 557.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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1846dbce9be88fe989d4662c36d53e05aa29f4be01b189794867ad1e594f4c6e
MD5 8b54256dfc8bfccc6e07048fd8797154
BLAKE2b-256 36019483e0117e8f7e6bde43168f959c1f09b6dd8ba115172aad9f6982d27788

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 86d69437519efd34ae48c1de3f88471b082b8068f4e0db2f7f3fecf7e4c513af
MD5 59b0b01c87ac4b57df9bf644b70468eb
BLAKE2b-256 850bcbf42942ce207f3458ab71893641bbf11db5d08b8b0a91d2c6926399e869

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.6-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.6-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.6-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 0ad7a5366f5b40974f0b43f4bc84c0c8a77cc507a2d9c84f2cadc6e850dc2061
MD5 092d9b092d55a1626ba057b1552bdff0
BLAKE2b-256 63d08ce48b99f398eec297786ea8162cfc063be2636e0f4cb61d07ad974e89b4

See more details on using hashes here.

Provenance

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