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

Uploaded CPython 3.14Windows x86-64

yarutsk-0.6.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (659.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.6.1-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.1-cp313-cp313-win_amd64.whl (544.5 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.6.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (665.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.12Windows x86-64

yarutsk-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (666.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

File metadata

  • Download URL: yarutsk-0.6.1.tar.gz
  • Upload date:
  • Size: 212.7 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.1.tar.gz
Algorithm Hash digest
SHA256 aaa4b2fb180370f69cc6c3ef0c7d80c176047ff3244204775137ca3bb99b9ad1
MD5 533dca77a84fa9689ff5b2986cfe7c2d
BLAKE2b-256 c526e2706badadd555ba8081f0938dc08de414227c6b7af6f57cb63b6c87871d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 538.7 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.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 54e9d58beae3f001b3f3d03b8015f76e4dc19b46a0f013687d0ac82e514393bc
MD5 c9a0e1faffbd8b99e992b9c88cb373d6
BLAKE2b-256 0c427f94b1c638e3b4d8338ede90d1cb0e3cd947e5d0449127630bc439821742

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9fb931aa89664fa2b156e57f4abb1d1bdc9280cfa1ee28d31ae2d05bddd17c8e
MD5 47de95d8c15708a7a573aaaf7b95e974
BLAKE2b-256 9d5cab93c9e926683bd66e0f545edc639a080c258fa5d1e38d8731254a897052

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.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.6.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.6.1-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 4d7dc3eb364941a0de9e8f3c89be95a6c939d0aa86e2d10d7ca6fa7f92f705bc
MD5 4a8df14d72da44c028b8a4746bc1225e
BLAKE2b-256 2a17f4ee335d7aa76b90e375a412a6804773d382045725b0b6ed2c9be2f9773f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 544.5 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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d4058d0862097edf0dfb3683eee3b59d54f21b4ee319c696c8c0da60fe40c9eb
MD5 f722405da9b1dbb4a2da59e9afe7d686
BLAKE2b-256 6cd8ec35d32b9b230395835e958f408154b7a8e1fde93eee93b55a1f3aa81e27

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 01c358b16927791f71433e100eef7b1ecbdc846277b3e0ed7e2f1954b1cfc019
MD5 24933c1fe4b41be0bb69175d79e81590
BLAKE2b-256 6a20944f05c6bddaed02bcaaf3875b5e943eb28a103993e0f255331d96b30b58

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.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.6.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.6.1-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 3dda992c0069654297a16636eda6bb8ad3eddc7af17edcc472dc8630e332cc84
MD5 8601da8766bfcab91406d61605119ba1
BLAKE2b-256 b58d6ff0b15969127cd391ee90815fd50ac9a1975195044b3a51dd03570ae49a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 545.0 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9347e8a3a33a174058ee1e27bea0f67a6ec9822a084945a5f6034e3489176c0b
MD5 020428cb1556c760b6d489d2f00f26f4
BLAKE2b-256 3400a637c61118435ace900c65d7b700ed90da71ae24d87ca80a2d37529c4f34

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5e2bc1c2e2c3d9ca4b78d68c72caf00f9c5806e6f8b921291ee3720d2c8c26d
MD5 f955878e285ec1271c96439e88e5c352
BLAKE2b-256 04ee73d0f107184274829d329d37f0a17fb9e045a1f65b0875cfec934e4fc5b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.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.6.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.6.1-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 862bbbdc4778b1e591d1fcfaf833b580012f1a707dcc7e9378435036ae28de01
MD5 81cf0c9415d7fa22fce2649982d80731
BLAKE2b-256 bf5489df8355e956bbf830829b3f0bf172fa572bbaa2d544de13004eb266ca35

See more details on using hashes here.

Provenance

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