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.2.tar.gz (228.2 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.2-cp314-cp314-win_amd64.whl (549.5 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.7.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (673.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.7.2-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.2-cp313-cp313-win_amd64.whl (553.1 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.7.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (676.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.7.2-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.2-cp312-cp312-win_amd64.whl (553.6 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.7.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (677.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.7.2-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.2.tar.gz.

File metadata

  • Download URL: yarutsk-0.7.2.tar.gz
  • Upload date:
  • Size: 228.2 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.2.tar.gz
Algorithm Hash digest
SHA256 f6106a92486b63d3d834bd6da56dc3a3fa0fef4047eecdbbc9308ef0d646c257
MD5 1ed4325dc56c64dc56660b83a5cf66eb
BLAKE2b-256 7afb62fab7bf16da9830130f2a46d5506e6d85098ae46d88424410ad252b91da

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 549.5 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.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 4982caed92790197bd9c27c914ac1596d94fb5796e9cd84e00a64287457a4d60
MD5 4f3ff24b7c1098e7b457758aca7f03f8
BLAKE2b-256 c936c2b6d938122caf1ccd69997394e3a809ff268bd115aa136f623da23921bb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 da810a30965f9128b758755f6c689912345e9ddfc3a95c843b2d6779a5e0ce92
MD5 545081c772c3e44155c7169287b9a3e7
BLAKE2b-256 03f04b6b8af4dd465f225a155869b1e165df370590edfe07cafee09907a19ce2

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.2-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.2-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.2-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 be253f7fa329a1c3b3ca469f3061a504293134cde9438d0482e2a3393e0b58df
MD5 edb7bc225b9f7b294d1c21259809c985
BLAKE2b-256 3ed6630fe931fe1fff52969d24a3e9da478f24d8f28c465273c68b9edd881a0c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 553.1 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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c8f26b7620da58378c48b92c661e815577399b2421292b3252f3f8a91e99eeb2
MD5 84d4cc834c2512dcdbb378f09859ebb0
BLAKE2b-256 c02b0a62fda8db13ddfcf0efa1b98491795dbc2aefab670cf7ac0e8cb1af5bcf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6a443e85c59a9495010f1cc4174a1a6ed01ba8f86700c388045d8e50c2eb0133
MD5 539f2eabb41f1172df5f02a7bc0ed89f
BLAKE2b-256 f64f6e91b162712f6089e774b61417f1b33be71f252db0d393c4d897ee3a1018

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.2-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.2-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.2-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 b6d070390d50861ca4f2942bd2cf7fc9e620ecc7b4008f32f0401f6db73ae6ba
MD5 19d63f0b4afe7e5bcccf03b6c2ddc5ab
BLAKE2b-256 021b43fe9b844682d465c5818c8931df6b912d3861550e51e6da1dc2f734ac5f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 553.6 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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 81eb47181b9d714217a635225aeffcb38103bba1eec17b217da5e764d2041db5
MD5 42faa39fe5c117f43a8e949cf585e52c
BLAKE2b-256 71a05bdb37179815cf8e18741f9062f7481e70cb42be614b92238008ebaa01bd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b12d386b2092fef1098386869932825af41f72fa782c7b2f6fa646b674d10725
MD5 65c7dc3972c492ea366fc29ed0c4d1e2
BLAKE2b-256 fd253f2e165519c896b9d59f2eacbc0f2e68d8ea515efadd2525b8c311e9d566

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.2-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.2-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.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 61c60cd5573b948f03b389b262bac689fd427dffc1e3d9cdfb9fe353706d0c23
MD5 fd4a59ff4f7e65866845ddfe82efd37f
BLAKE2b-256 8c2086598e0016f1f5a8da3e46a5d086e853c8a556d98210df7f9517f6cc2a5c

See more details on using hashes here.

Provenance

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