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

Uploaded CPython 3.14Windows x86-64

yarutsk-0.6.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (659.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.6.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.6.2-cp313-cp313-win_amd64.whl (543.4 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.6.2-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.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.6.2-cp312-cp312-win_amd64.whl (544.0 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.6.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (666.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

File metadata

  • Download URL: yarutsk-0.6.2.tar.gz
  • Upload date:
  • Size: 220.8 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.2.tar.gz
Algorithm Hash digest
SHA256 7c0f583273f51d5448b94429f9f7110add440eab4ad9fb150134da953ec66b98
MD5 e3eb5e7fab8844e76008661b9140cb50
BLAKE2b-256 4d37766e1f8cde38cd490946bd2d10e607e5ecce6c18aefc8a1ba1644dbe4c6a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 537.2 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.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 c53b1836bb0d912a9499b0eba9853f5be5030ab60ce3fbe99e1a02917767508c
MD5 5da4b2a3a47d1261fdd79b8502d87d21
BLAKE2b-256 2bb8f466bc4a960a10769f749567262971bce19606bbe496831d98ee330a1c5e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cb5331bff193c457b85246ecbbf4899cb0039553b28746056de4ffc80650ff88
MD5 a51bef23bf52bcdf90ede5aed7939bd1
BLAKE2b-256 a730e855ac2d2b846064a5bc3c72d9da3026df149cfb6be24e951e8222ba53a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.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.6.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.6.2-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 9e781290f02de70c6d3ba4e858319090b888da06456d773ea92429b0f3ddf639
MD5 4f4ab914a4a1075f5a7605e559bbdd1f
BLAKE2b-256 a42e91db53ac9c4ce131352e107c07c8783cc037ebf4aeecce3fee34e3813501

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 543.4 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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b41c9202eb5bc2a9fd27da2354560da010a1a9579b136002d822b6d59a56000d
MD5 af2357da1e4f3d71154c8788edb0de99
BLAKE2b-256 1abd8daccb41ead2a89411a24677167ab741891684352ac29720b55d4464bbf3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 69b8e5c15556f2a1c0c0f61db85565182a841fc393a3995e07dd447eeadcefaf
MD5 657bdf93f1ca6539b52cf519aa8a24f3
BLAKE2b-256 a2231be8f59669e39ec459e753d0de6e14d3eb3c07be97937e2828e6110a3cae

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.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.6.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.6.2-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 c9d7e9398b2e70f55267f28d13b14d8c7461f2826b4e2e129cd24baff1909877
MD5 c089a682a10da837fe14d22db26d86c7
BLAKE2b-256 88eb4fc06bb70625a55c1e0be2b4e612409d05b19944ea1b69e3b3c0c6dd0ec9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 544.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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d6192dbda27d4dde47bdfe4ea3ef780f8e6c519f2712ea19d17caca321ab6c7e
MD5 c5ff396b7b6cd1902ef5dfe2eec616cf
BLAKE2b-256 c3361e2533729cb8ddf5c76a319799c480a72c8d0896bdb90801bcc30e1a8982

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54da20366a36ef18a7748b588326f12b206d37554a69dbc1a561eccb92a07cb3
MD5 77d601919605e5817e77147c61b36d70
BLAKE2b-256 d945c2c81eb2b082adeccd99df1f5dd4a028f97ec372c54f9bcd859607c6ebc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.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.6.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.6.2-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 3403b9a47a8741ff5bdb978e5bdbc97592e4105f213d0361ca38a40815d52fdc
MD5 d0039d1997e7bd0815479eff6107f50a
BLAKE2b-256 dcbfbbc26fff757330bb5725dfc9561b697c330d35a727bfb6e96b6849c978f5

See more details on using hashes here.

Provenance

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