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.6.3.tar.gz (221.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.6.3-cp314-cp314-win_amd64.whl (537.6 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.6.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (659.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.6.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.6.3-cp313-cp313-win_amd64.whl (543.4 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.6.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (666.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.6.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.6.3-cp312-cp312-win_amd64.whl (543.8 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.6.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (667.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.6.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.6.3.tar.gz.

File metadata

  • Download URL: yarutsk-0.6.3.tar.gz
  • Upload date:
  • Size: 221.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.6.3.tar.gz
Algorithm Hash digest
SHA256 0ce25290e512d163f320703076293fc4ea1d6d5ac12c55d9f30305106ec98c66
MD5 503d9171c827261764e09917702e37ca
BLAKE2b-256 a64dbe2df49cd1f2e2a7292a6389c301e7de74cb41a63dc5c93663a5064c99e1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 537.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.6.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 0539d6cad8850ad453f43b1269d2194a1c1d8548af60142bc2605036f62fa350
MD5 6b1aedd2c8a28de7d5944ee1dee18a2c
BLAKE2b-256 d1eff1df781e420c17224a22b6165800436a8f9ce97784680c667399d060a1b1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 293edeac262eff25f0a2c611b7e6f8149a8b5c9bba2e337c1d7f03bfc0885667
MD5 4998a1c5478729c673c3050da453192d
BLAKE2b-256 3a2c323f5b5bf7ed683c3e159fb71b26921b9d7fca7ded48da88aeceeb649562

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.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.6.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.6.3-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 307eef385c5e8fc7b2203adc2b4ec7c0b72d51b7db55e50fa0c0fec0af31f503
MD5 ed29164a0d765ce1b76c7116b9ed8d40
BLAKE2b-256 bfb12573a0840c8fee234afb07a2f3422526d875f7d9dcc4c4b88178a353a49e

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 543.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.6.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 25339bc340aebc01195f1b47d0c09fdde7e23ce2f2a64ff213988e8b440b99fa
MD5 dddbe44ce7a26f6b0a571d1182deae81
BLAKE2b-256 2bfad75271498dbae43e2e7d617ce4e96c83bfbfdfb9deb24de48d7221401249

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb6414022e1caecc0e828db25a86c6f61cc72b7cbad18c165300484aa968a030
MD5 e1a965409e6a31db6681ae69c5ebe1cd
BLAKE2b-256 94d98d35d8831c4e96c768792a6d5abe1d167da8842c74e106f5fa447527147b

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.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.6.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.6.3-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 9f5c7323afe4cb96ebff24fed7d5d77d01772fd6d610eab1a7410caf08073bed
MD5 279b00ecc6add974f2335baf27b5c451
BLAKE2b-256 e616330e417277541b23ff90dc17773329703e3d08c8257cb6ac9027695f63eb

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 543.8 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.6.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1266696366a0baad708531200ce5768e0aeef1c170c6e9a5adce1890627214b6
MD5 c71e80fb9ae9c53e095482b496fe013d
BLAKE2b-256 c1b9ad3235f7b26151069d783a790b4c3ea2a5ff86645ecaabd5acc1cdeea5b3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e3574a1c6a051de7e671ec576e8b1640a4126b7eff6959cc97caacfbb23ff1f9
MD5 87e0b2f393d3ceadc81dfa8e683f8c1b
BLAKE2b-256 f12d66153cd75d69f9c5bef03472b8e72c379906027c61a5580f7ea05480a14b

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.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.6.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.6.3-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 8117492844e02fa2833d67b9134d8c7e63fe15cb5950d8430777740ff35c5817
MD5 f0a63e661c83e7755d790af9094105ee
BLAKE2b-256 3d132337253c8f4dcd10e4be5aa9c0418a4c59a239b8ce55584d7688a761cc6b

See more details on using hashes here.

Provenance

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