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.4.tar.gz (209.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.5.4-cp314-cp314-win_amd64.whl (541.2 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.5.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (662.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.5.4-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.5.4-cp313-cp313-win_amd64.whl (544.6 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.5.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (668.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.5.4-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.4-cp312-cp312-win_amd64.whl (545.3 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.5.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (669.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.5.4-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.4.tar.gz.

File metadata

  • Download URL: yarutsk-0.5.4.tar.gz
  • Upload date:
  • Size: 209.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.5.4.tar.gz
Algorithm Hash digest
SHA256 71ed163545b0fa8795799d500c5dc55a9da1191ddabd057f6c1c6c461a4e4a96
MD5 4522c3f07745216d7ae3b3c2b9103911
BLAKE2b-256 b3137e50a213944bf95e8874a6d8641d8c2ba573ec10d14035d8d241c4ec6492

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.4-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 541.2 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.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 ea91df44af89a6336cbfc9082067c40830b3e9f143f807a6d74c47f1ef2abcb1
MD5 c30c279a1ddb8bce64e8f5a4ac955012
BLAKE2b-256 a84c605d433b79f7f75693036c9d82be2ac8352149d1752a3208b7ab14b1e1b2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a9222739af88b4ac9ddc93c0a89279c971f1066d0dcbda8af23d53230cdd3d16
MD5 70670f1047eaba1427680403a33c9480
BLAKE2b-256 bb6a1ec4898b216a96a121bffd6663fefd339d2d55f0bad1ae094ee126d6bef1

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.4-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.4-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.4-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 ea837ac2ded501b6fb21d9c6655391a2fc289016a8473a21dddcc4dce55401e4
MD5 e3cd3ebc37abfa0251db74ecce6538c6
BLAKE2b-256 39f7d695a9e203139b707886f5b931c46ddb8d825f16b8acb4c983e06a7e72be

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 544.6 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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 830a43cf409cb9b10330b8d0acc315b869e89247b18daae55f938242a7a01745
MD5 a3e6714a3c46e611cdbaff3cfef9507c
BLAKE2b-256 d3ee1efd1fef8d49e398eba2a7056fca96b2ae080e286137e6add2d54c7afa50

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f113ae54877e2a82143a6e3a09b7ffc0e7c9d1fd60262c7670793b1911462094
MD5 92ec622a0c113c4186ced31b943fa72a
BLAKE2b-256 64b5496bd84d20506155fa6209faf9d6c382fe5072dce3d716f53dac42384c4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.4-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.4-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.4-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 d9ea8a3c965597b965b724037c166a6d8a55b2ecdb2a58063f7a2e34b79f96fb
MD5 b8a396c5dccccb92a8b4f8e2640d9a0c
BLAKE2b-256 c1aea2ffa3381b555c60a5bbe18e30a60d09df07bfadfdf9e4afb8cd7d8d5933

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 545.3 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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6eeba441f710cfd4b9743f8242674c367379aa6f60317f8be8714f0d1835e6dd
MD5 4014592d2bb6a32302b3cadaad7bacf1
BLAKE2b-256 cda15f1684dd590fac2ff7c6fc28660668f1c8a06e1205361f6dcdb03e57a1c2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8fada1f56ab5f5ca3d31108493d8b863ce2dd857a9030d20871c5409b2a784b4
MD5 1ce307353e79e5ec187a9b3da6051d8c
BLAKE2b-256 0a9167b97a1abc573e2e861d60e4cc22c34fccda930509e248b15c9d9bd66409

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.4-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.4-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.4-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 3324e0cd11b3e9abcd06ba17314b6c86a78d94f7bf6cbc2c411db24ef9aca40a
MD5 f44cfc4126c3eec658eaef714a8f8f7f
BLAKE2b-256 c0ab175c2563d79178225b17690978e3ae15513c3bbced063f4157a9e5a14b08

See more details on using hashes here.

Provenance

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