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.3.tar.gz (208.4 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.3-cp314-cp314-win_amd64.whl (542.6 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.5.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (664.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.5.3-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.5.3-cp313-cp313-win_amd64.whl (545.7 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.5.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (668.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.5.3-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.3-cp312-cp312-win_amd64.whl (546.2 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.5.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (668.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

yarutsk-0.5.3-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.3.tar.gz.

File metadata

  • Download URL: yarutsk-0.5.3.tar.gz
  • Upload date:
  • Size: 208.4 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.3.tar.gz
Algorithm Hash digest
SHA256 283b2dbf7516e1571e501af03aa36f1ba4d2dffcdab7a1b553df291eacb74495
MD5 c00f659b597f74308eb7630c8250f9a2
BLAKE2b-256 42ffe5450bd0d9c05e7b9c9bf208677663af38f2889273fda3bb4ce85b42dbad

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 542.6 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.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 94c2098e99e01eebd8bda1ad908372eef3b3e3f6287ddde4be211f7d243acfb7
MD5 b94e87a5b3f4518cc403d90d7e198568
BLAKE2b-256 c82fa88a6afdf735dbe08f4f476f02d35b6ac2ecce740cbbfd3d873608d62fa6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b7e89c460d2e1d5dc4c38e01028cbc119b37192890214b884bf9014be55db9c
MD5 e4501d8cdebe3b61f3735609972e43e6
BLAKE2b-256 ec07ad1a601638cdbf8310d851c0c886b2ddea7ee464af7bea445888ce647c53

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.3-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.3-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.3-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 14fc9002420624e213e98dfe879076f6183f5c512d4c6c60b40b79d22e61cd0f
MD5 b72a5e05989d66db0097278b7b73b3a8
BLAKE2b-256 5547eb14b15ae990a8e25560fc8d0ed73fe68cc582b184e56cc52e62635db03b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 545.7 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ae29b31128d2b676b33f65c1c3968d9d110da080a48d6bfd469326bc9027a35d
MD5 8f90b14d83879369a86d238f39ea7b9f
BLAKE2b-256 de6681169604d14c6874d95a16536a3ad2674b312f41d936a06f2f5a49048a5a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 322cdad5853195c7b2a36bb819329d64a7c52f72c50640b100427053365ff95b
MD5 7d00d481d15807b1a8f2bb913e354695
BLAKE2b-256 c5d7412882c0a3e043e1206f3f4fd3b2c7297e9c8e443c1ec04e58dd1364a809

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.3-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.3-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.3-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 848d31f565df21274cb676abbe7eb627a3322b1b3bad8e1fbf00d868fa212f47
MD5 5d7ad44b48d201f8c55573e9ab4c2de2
BLAKE2b-256 b85fc8db10a18e9c7ae6b013e96bc587b23997dcf13fd8287af31488bd50b1d3

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.5.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 546.2 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 585c74e1a4f46fe0ea4b4e7650838bb1c1b9574cdc3fbe404e9096b411529761
MD5 8993e40196bf31e87e5f20430157cb9b
BLAKE2b-256 d88bf21edadcfa84ca6e6a3fec30c5c901203e49064ad1632ddb8eed9b2217d2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.5.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 565d099309f9ad6923b1c71f4329e8e0d63021d30081172e3357f8de53210fa6
MD5 1ff8892363cf02b13a0116e105d8d745
BLAKE2b-256 665181c9585b64d742a327973b22acbde58bced88bb1286302b77650e154c4b4

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.5.3-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.3-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.3-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 1016b106ca5770bfe0348062891d86301f19755bc53478343de14cba4902afd8
MD5 6eae0c662119a14ba565d8cbe2b1327b
BLAKE2b-256 b7e38f43ce5b0b8356de7a32486b23ccd02335fee9a905cbfe4439e5d74d1cd4

See more details on using hashes here.

Provenance

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