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.0.tar.gz (226.9 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.0-cp314-cp314-win_amd64.whl (549.4 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.7.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (672.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.7.0-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.0-cp313-cp313-win_amd64.whl (552.4 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (675.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.7.0-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.0-cp312-cp312-win_amd64.whl (552.9 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (676.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.7.0-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.0.tar.gz.

File metadata

  • Download URL: yarutsk-0.7.0.tar.gz
  • Upload date:
  • Size: 226.9 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.0.tar.gz
Algorithm Hash digest
SHA256 303cf0427f0acf9cf1cab513177eb284ba4e621e3b962a4d6ddeeedc1d0d11b7
MD5 9b2f8050d532b4a7c0e91490fcb08ed0
BLAKE2b-256 d7361a6cb20a0e2203488bc19cffc4321445889ab0217db00b5d28f65c425879

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 549.4 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.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 6dca5724d64e79dd044c31540020377479e57420469b912f6855375d86dc5df5
MD5 f2803cc91ce0a54e38cdfa9c4b4c6700
BLAKE2b-256 e22db6ff7d39a0d3e51fe1757bd4757dd5b3faece86776c85daf699651fd3ab5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 326261ee7a403bedd84b06740b97b3ab0e33280d13a106262b7e95b853a52a89
MD5 3856e9bd2d3d6bff268e99b4a5f80819
BLAKE2b-256 7edbb42b48839ce652776b73178d7a7ca84303906d54570e155d47fb706e2e8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.0-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.0-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.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 9ba015640503da76817dda20a42c418496f092025e2b93f43348872fd729d6d5
MD5 ff8e8e6900708471777e7f2f0557d6ff
BLAKE2b-256 7d216f7077fb6f2f8a5d69bda51b51e8870526427c09462fa0592820a083eab0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 552.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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 dea5338999cb156fcaf5bb1dc88c656236a7b21c795fca81946f44a1e5904783
MD5 4503f825f71bc7e49026b25363d47af4
BLAKE2b-256 c7f74332ec34097e7f0bd3ab88e43ab3a88e5b8a9a3cd5c355c02cb35e0975c3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 14296a6a8039c1c8ae88a4d00bcf48c68008b1dfee0dfaa41c79a907282f13a7
MD5 3329d5cb43066369986578ae428e306a
BLAKE2b-256 35d2538817452a534c0749a284ff7373476ca341ea515eaa362951176219d691

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.0-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.0-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.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 283bb172ba400d94ad63b2ef5598cf95b794a0b547329e478cf12559a650f1f6
MD5 2c83a8d0cb45b6eab6e2c0c53f608d84
BLAKE2b-256 ac0e0023a06a706cdeef11f6ccbd1bb2522431b8f9365fac7d774bfdcca6eca9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 552.9 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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d6270776170c6560e9d8f46dba2583c34a9d70aaa880f486107c93ff6023a0f4
MD5 70e9cb550bf2c4c4935cbad04e2d9691
BLAKE2b-256 4f81c2e50d7315a70211e8faf0a9f926f2144ba261c8e6a73aa4f7ef24e4a2fc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 87490cc64d0d33f29d1c7e9e504875e341f0fd70e37994bfc6f08e2d3c73f020
MD5 61fea9f0c10fc6adc43b2bc34da2251e
BLAKE2b-256 bcae3e4fbb32d23b94d4715c6c8816890c03376f22a53a099bbf054c47013b8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.0-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.0-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.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 18566d474f3ae355f9625042d7089292ad4fefaf2a903e7225c841672930def3
MD5 10ff063e62ea94c41c13be079e80c734
BLAKE2b-256 f1acf938393058e202ceaca7c62eb74f310ebefb2a0c4d49c745baae9292e408

See more details on using hashes here.

Provenance

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