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.3.tar.gz (260.1 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.3-cp314-cp314-win_amd64.whl (561.0 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.8.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (680.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.8.3-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.3-cp313-cp313-win_amd64.whl (565.1 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.8.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (686.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.8.3-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.3-cp312-cp312-win_amd64.whl (565.6 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.8.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (687.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.8.3-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.3.tar.gz.

File metadata

  • Download URL: yarutsk-0.8.3.tar.gz
  • Upload date:
  • Size: 260.1 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.3.tar.gz
Algorithm Hash digest
SHA256 4de76bf6d0bab8e1644741578df3c02e85c6a78b870802f2dae715848375ba7f
MD5 fbaec4e404de87a34fdef541b61f092e
BLAKE2b-256 d9868cf81af4394f0d2af52d86e3fd56879e7926e2c1e714b83766799a0b3d42

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.8.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 561.0 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.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 f83a532c257cbdd74165f766b012fd9951623198ec1e33501376935c1c61a936
MD5 232e23e88c5d045e34920958080cec3f
BLAKE2b-256 af643edc4c56875b81801a5304a971a9ed060280d78e0f7fe482eceb00da732c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.8.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb82674477ae0677788bac7d4bf6c175ed39ed02dc109a798990435934ce1429
MD5 af217e2f41294029602871d19da29af4
BLAKE2b-256 00c7ffa49a63d52ba1387397cccccfdc4cd34e72e68b1288714e7e6410353698

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.3-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.3-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.3-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 b717b05244d3252ce68a3ab958fcbcf06938913448f98a65b237ff981cd12f06
MD5 bfa4eb8607b8aacaa06b5423faecb4dd
BLAKE2b-256 b534a225b542c95b41330477227c783bedf3efc77e4e60707b47f9219a00dec7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.8.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 565.1 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5cfd5c41f2f358cacc5a1ade9cb6ad6e6b107da73b6f5d3eabbbf62808e052c2
MD5 a1136972a07b8206909510268f8ee6ae
BLAKE2b-256 605415bf5567328e020e903836c7e33b2a4e9e260c54b16325e1ae1134f4cc97

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.8.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d12a1f59a7bc8442b0c57edc63242b38843ed75225e12c2a67d0e501d63b9929
MD5 2d054ba06b407aa2528fbee7a8960c2d
BLAKE2b-256 107a398b8af410f723b857d20584924c275e904a020d184fe5d3b0aaba40bcf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.3-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.3-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.3-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 e34b29e43ea54e081582ea124db717ab236d2132770de00343f4bfc5d28dfb60
MD5 4b3a300bb2a0c40cf1a6d08c5ee3657b
BLAKE2b-256 3b25f598bb2b84884795e6e9d4bb0ad3a4e01c81d3edfb694c1dfc6f680f2305

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.8.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 565.6 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 20884977e6443debb4e7219784481a5672230607f0d8b15126d410699eed5501
MD5 b43aec5eaaedd40c8b2ac9ee16be1604
BLAKE2b-256 1cfeb2bb62f6c03737c7737b52f8d7b999f988a8a2ded064b8be28d63339b882

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.8.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 05f685407fd2fb38163108bf9e9d875574f02bb09a563dfd7c0dffd5d73de469
MD5 911838ed0b95614548be9dbdcaaf8c3e
BLAKE2b-256 e099911acc02fd7163e9404800f40798a8fae426b142404a96a8008cb6bf5ba3

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.8.3-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.3-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.3-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 b258493e1d8ab8ea067aabcd3bfbce67711b5a9b610627fa18b47f81fb118231
MD5 05be0a2b6e499087907132c4df08a45d
BLAKE2b-256 0896665e970782771dd42301a475cc753a7e6ba65699c405e15a04e0e9adba1e

See more details on using hashes here.

Provenance

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