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.5.tar.gz (237.0 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.5-cp314-cp314-win_amd64.whl (553.0 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.7.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (674.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.7.5-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.5-cp313-cp313-win_amd64.whl (555.3 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.7.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (679.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.7.5-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.5-cp312-cp312-win_amd64.whl (555.8 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.7.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (680.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.7.5-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.5.tar.gz.

File metadata

  • Download URL: yarutsk-0.7.5.tar.gz
  • Upload date:
  • Size: 237.0 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.5.tar.gz
Algorithm Hash digest
SHA256 8b7174624fb4c325c673fdce80009300186db52de47aaa803d6d6f32a97ea0c7
MD5 e452e7a83b98bf64a327de8b4e883d1d
BLAKE2b-256 b209d36b3ade3d24224b619a02fbcdb0a47aa8e68529b6f73ef96668e365c178

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.5-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 553.0 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.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 f40a6c09c630920841363f631d0dab6b40f03d66562646c4f8a3f6a56704f10c
MD5 d3ad961aed4123595f43fce9b98de429
BLAKE2b-256 599d089425f4f13e3580e2561adc8da3746ecbc0542dc0607e74277636c2fe38

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fa56b1661ccc16d259ffd6511a30cd499ca55c0843c8485d4a00aef4a5a69972
MD5 f06304579ce40f77b447bf4bb170cfe3
BLAKE2b-256 0146972916f53c65bad7ca86a58cb4db412ee5225f07fe08ee71061000d61bc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.5-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.5-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.5-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 0f840d0d957ca78770f326700534897724ea1fb52b9488dad00feaa01d3a8195
MD5 29f291e1b46c64d4235d4fe9e0299758
BLAKE2b-256 a03dfbcd34baa7d0faee52d96fe129273f448e7fe9787a1674c4eb7f9ef1e915

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 555.3 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.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2fe556ec6b65c9d9c3169147896cdad4b1e1b5d6e00699779fe9e56e7ca1a387
MD5 3c8852fb6423684d4145ffbe42291d83
BLAKE2b-256 fcc6ecef2a17189f022d733c13e930f75afb5714f604d1a36c1f731081ae6483

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84c731dc429dd38a180a17ba718ecd3364017f1aa76641efe73528d96e6085dd
MD5 aae9d204343cbada4ceeda762fdab309
BLAKE2b-256 4959130b0af7a4caf667ccc49fcce15a3a67f239ab380bdce488615c77275f20

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.5-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.5-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.5-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 a86d96689d76d0119e85efa9198bda975e546008f17734a8f6f9a6620b47564b
MD5 b98e860f9ee096690b1e19c61542b267
BLAKE2b-256 c0b17b588f6cd1d0faa2dca2cfc7c02fe96b3e2f4409196b332a280ba38dad3b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 555.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.7.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 54126fc290889825b434f4f5503fecd6539b7cd07a6adeafff41803b3caed53d
MD5 5d920ec6099bc8fc527f407d56cc5814
BLAKE2b-256 b93305f4a49d47e50745de7118e8715801883826e29426bd8d0ec8a1c756cad0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80fbafe0756a87194212dba02644de4445f3b88a36ea8d021ea96c285a59f55c
MD5 4a6af9e57cb8bffdb65c66d8ae518f30
BLAKE2b-256 24edf21217b006b47b5a1810c31f0266309cd29bfc1b770f2da2c3bd6f5e24ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.5-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.5-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.5-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 ab04094da480491a52c9636223d6b6b55a59d9877887925459b360fa31423ba9
MD5 e553346af778156ed5bb397fdc8888e4
BLAKE2b-256 ef3c2ad52cc5428da9e56f12c3e6032047d03607f925df736a6463c67b197e55

See more details on using hashes here.

Provenance

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