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.1.tar.gz (204.0 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.1-cp314-cp314-win_amd64.whl (538.1 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.5.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (658.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.5.1-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.2 MB view details)

Uploaded CPython 3.14macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

yarutsk-0.5.1-cp313-cp313-win_amd64.whl (543.0 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.5.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (665.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.5.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.5.1-cp312-cp312-win_amd64.whl (543.5 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (665.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.5.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.5.1.tar.gz.

File metadata

  • Download URL: yarutsk-0.5.1.tar.gz
  • Upload date:
  • Size: 204.0 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.1.tar.gz
Algorithm Hash digest
SHA256 e5c0433c426e97e92da04e825c46b770d97ac0c2c9f5308575015652ee4fd375
MD5 d8e288b5da0c3aedb049408c52683053
BLAKE2b-256 10b3b1855911487de2ecd16da0b69cf0a9146dcc75af1bec715272561cc28fb4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 538.1 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.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 d1fb72254fe454d8d4beefc8bdc2939333a95b0f2642810d8834485148574a5c
MD5 193faaaa0f022948c9e0906aea874119
BLAKE2b-256 b9e14fb82293c4444a2069d971f35b5b1e1230e00245685dd665c3c91325fd21

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 799c90f99ff5d7e1459e8418d0886c9822cb57935e7ba4a622aecfd927e66ea0
MD5 0f4a2e95be6037aeb513e450ff00a6e6
BLAKE2b-256 12c19b6c2f643252c4f406d840ae5be275f6c99f014e2bb46a41bde063abeeb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.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.5.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.5.1-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 2446e199b69389f34a1ea064578ecd55b0d33cfab95a913e6cfd058d9d690071
MD5 c14511254db0ef053af567b2a22faad4
BLAKE2b-256 88ce90c66bb15cf6c46a5db161e0b8ac0cbb8d497dac8753730e03940d219ff2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 543.0 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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 50b340d4d75c88dde2047aa190d2995b138fde5a449d91d9f3de915ac61164cc
MD5 8ffd90398a7cc94c7190238b188f51fa
BLAKE2b-256 e51a16464eefe361c1ce935e50e76d8c4e67bc201a71036b09fb29bbf6af509c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 42c98f153ff7a1cb7f14d89a7d98a54231912d479d909dffe1e3f3bdb1891c11
MD5 4608c6eb37d071161eb4d061c6ad0f27
BLAKE2b-256 cb2ad7b7426469ccad6555f10a19c47ade8cf5bc327938be062f5e4ea8097277

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.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.5.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.5.1-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 eed717e83e2e236768622e3871ea4e2a6d8d15d89528e8522c9e998b38b90b5b
MD5 bf860b14c00fd15752376c2c6b4ffe84
BLAKE2b-256 a0876d9105d910b948043302623dca0906c589c13d545aa17e1feb1798e4a0c7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 543.5 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9de32438f3598809e136e38ea5347b86b12c4e3388639cfb8d37e1862d2404a4
MD5 84d2c9ed580622c2cc7ca9dbab2072c4
BLAKE2b-256 875e401a42aead7428042f0966045daedea73f1a1efc1a41fc2db27f95b9ce0b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 065a08c27156e8cfd5d11d3baec1d3c1127726e6fea296b14639617553678afa
MD5 c4457c50bbaab05b9724b93d5e1777cc
BLAKE2b-256 da4bd7bc35a45d7e02e058b209257105c6328025be40c66b9f4daa3229c3e08b

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.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.5.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.5.1-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 f82fc7b05afaea86b24884bcde2614eacb6176219b57d81ed4d5223affddd649
MD5 0301ee5949177c1acedcfa17e92496c6
BLAKE2b-256 b751cfc8ad4e2d114a73d3c5a00d6447780c8809b5016883913cfc10ab77d193

See more details on using hashes here.

Provenance

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