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.4.tar.gz (230.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.7.4-cp314-cp314-win_amd64.whl (551.9 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.7.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (673.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.7.4-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.4-cp313-cp313-win_amd64.whl (554.2 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.7.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (678.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.7.4-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.4-cp312-cp312-win_amd64.whl (554.9 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.7.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (679.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.7.4-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.4.tar.gz.

File metadata

  • Download URL: yarutsk-0.7.4.tar.gz
  • Upload date:
  • Size: 230.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.7.4.tar.gz
Algorithm Hash digest
SHA256 1963a606c269e0806842b6e37aa2c1255bdd37b25fa7c0d3d7dba5c907c1fe66
MD5 0d6d7a5b945d254d2c71a766c3fa09a2
BLAKE2b-256 52eeedd631e0ac14a99684b8826319da59a6598d2994de12b257b50bfec46501

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.4-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 551.9 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.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 a26f087ef450ea7a91e4bdf28a47f03b208de4021d6bface6b62e1a1f6b5a510
MD5 ce37e094286b9283c10b07c604dacf58
BLAKE2b-256 a3b74b52ae944e67b73bd0fdea0ba99d01c4f4b22552d0f19a4f2dd7ae387f0b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b22a697d749631fc64feefc3352012f51f86628e53bb0e7440c40fd2761c209
MD5 6b2d305aa4d78055a40486a1f672e2d2
BLAKE2b-256 f729ded09f490d881a1e34979972c548b867c73096324df89fb7b557379ce863

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.4-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.4-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.4-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 fd6043514e5803305c0668357df5e602d3bbb677437defbdafb6c1298f6d0dc5
MD5 163bad5d23b754213b63ef8d78220159
BLAKE2b-256 b79842d7799c35acf8dc0f84ee66168a056e481fc1c6137d6951b05a904394da

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 554.2 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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f4b784ca5c32a411ea5b25ea5b30c193e70f01d5289c233ab331758f8d075c36
MD5 bc0609dac5117b4b704e98d86cae84e9
BLAKE2b-256 3d6f527d164321e02d346b1cabc344adbce9547f000a344550b749831e71cd5b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8c8553a58057cf87e4aa0f42d8573f5f9fcc06241e47fcc34660389f9f437650
MD5 88ea64cf59eaffc375cf853ac930e900
BLAKE2b-256 b2e31b5e101ca1e7b5fc38b1118add916957823d8c5e4f8b2aeeedc57635b4b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.4-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.4-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.4-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 b783b96e5e11d0b9ecbbc401400a0c49146abd732cae3c5ae790a47c1f387494
MD5 166ccd7e5302651e98879d2273d1ddd2
BLAKE2b-256 af507f4a4a2f2181f2a86e2d7b04b1a92fbe1dbff3b1f6b692bc2a8134123291

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 554.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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d71ce2223662707c6342b5a5a8e84d4645a0e93d8be4dfbeb97beca2b89a7e54
MD5 14e408a0fa50b603662fdf75753f9b91
BLAKE2b-256 d99966fd559f2149c7003132d8debdeca0e6ecc1f884a35e0328afd1eff02a5e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ec406eec6794b0eb33660075f43aa278c1b544e75e6a6dc66320c8262118b65d
MD5 0f4affbbae161b41b7ea7783a1e45f49
BLAKE2b-256 efa07d85732e8a07ecc199d4b38d8818375d3e38deba48ed6f77efe208e6744a

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.4-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.4-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.4-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 dd560bdacad3688ddcf8559a80a98aba6d742425309bdc1ab268b32de9207bc6
MD5 e1a7a54d23668d49313c5cac037ccfbf
BLAKE2b-256 f773996dfd6745be660b15303cd782a104b435fb55d181481310edfba03c238b

See more details on using hashes here.

Provenance

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