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.5.2.tar.gz (205.3 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.5.2-cp314-cp314-win_amd64.whl (535.7 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.5.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (656.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.5.2-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (1.2 MB view details)

Uploaded CPython 3.14macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

yarutsk-0.5.2-cp313-cp313-win_amd64.whl (541.2 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.5.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (660.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.5.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.5.2-cp312-cp312-win_amd64.whl (541.7 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.5.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (661.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.5.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.5.2.tar.gz.

File metadata

  • Download URL: yarutsk-0.5.2.tar.gz
  • Upload date:
  • Size: 205.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yarutsk-0.5.2.tar.gz
Algorithm Hash digest
SHA256 1cc93bb269ec0f514307c7ade31659e7e3ba85bbd2b1d012691d9227e00c30cf
MD5 e1af2c1f54d4128201fad91a628bdabc
BLAKE2b-256 7bca8685978874c7e2b7f8a41c977396011620143d510385a01a8dabf62e5e9d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 535.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.5.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 3286edf57b2c9472cd8ac7e0922e52ece1cdd4078c9f63406ce4312bafb6f598
MD5 08d0488d93dcc7e0e37b1896d283bb43
BLAKE2b-256 004c4c57f403ae21e2daef5646d71968164023b599ba6ecd22a0780656ab8db4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c1cfe1afbada3112da82b4d7adebb6de493e52756f827a52f7bf4d361e0f88fe
MD5 b2c7bfa944f281f819d502ad2a5e9947
BLAKE2b-256 5b29a24d71b36cef4dc18f4b870aab4fbf784ed5a7b28f0fdb5fbc58c64a6382

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.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.5.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.5.2-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 17bb21c754c4403265aa9f0597aa7d42889ada268f80a4dbf23f1b373ab078b8
MD5 e4b3d9cd7012b41dbc4852ad601548f5
BLAKE2b-256 2e4d6dc3c7e64d492a1a3eef1618ffd590727888fd5065d34d89236cdfabc9d2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 541.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.5.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7aeac65172e3a0f42d0c9ace03ec1eb2d9032ebc8b61d764e25be875c82e9eaa
MD5 2a2929b5f6aca2969cecffda598cd608
BLAKE2b-256 707d6f16669fc7aa10344936c599b77df6ce75bdb0ffe8f7e26e92f1bb88be2c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 04e911d9d1c2df186b8e6b1a6231c1ebde9c7a760a3785756186cee5c15faa78
MD5 1db1b77854f70321aed30c8d2313c7ec
BLAKE2b-256 9ce638a6f24a1742365b5922dee67c563abce7c9375f9d322cff8d410cb06e24

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.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.5.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.5.2-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 0f6dbe8dd1da94ec9b1a8dbc627393f04203a5265623455c5b3f90c1badb23eb
MD5 84986ca3576071c388a329039f6004dc
BLAKE2b-256 c450f40986b2aa8d4a9ec77299b1f606feac3937779c4118fd7d6b55984bc775

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 541.7 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.5.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c8470404e95e7dcbf5cf865088bdcba947a1accd4b859d181d5f4d404f8717e5
MD5 1242a7e4fffef3c6f1242bc406eb115f
BLAKE2b-256 e6a637eefd61905eaff39b9b08309e029064daae37f4a408d467f814815770df

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab51c6977a0b5703d7319859b4d91e00c615ce7d1a0de45cb85ab6296829711d
MD5 8199f94dfdb1d53f3cb1751d8718f7fb
BLAKE2b-256 27d95f528c8e973931a53aff61e8777c154eecd1caa0828bc774950e9501ff3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.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.5.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.5.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 c8c90b185c72639c44f8ef631d7a77e9e94d715a877cf22ffe646ea5616e029b
MD5 258ced8a624ee453ac74fc494cbd6997
BLAKE2b-256 9a247ed9416b417181fb8f7ffc2a4f65d17ecbc13e5600dc3ab1e80d6b99c925

See more details on using hashes here.

Provenance

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