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.7.tar.gz (238.1 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.7-cp314-cp314-win_amd64.whl (545.8 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.7.7-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (668.0 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.7.7-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.7-cp313-cp313-win_amd64.whl (549.2 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.7.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (672.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.7.7-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.7-cp312-cp312-win_amd64.whl (549.5 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.7.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (672.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

File metadata

  • Download URL: yarutsk-0.7.7.tar.gz
  • Upload date:
  • Size: 238.1 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.7.tar.gz
Algorithm Hash digest
SHA256 d96c7016930233935292165cda7d156ab1e6ed215e053ae3ebd3f73ead1f2274
MD5 a371646b3540c9f7245c9fcac83ee65a
BLAKE2b-256 314069bb7b242cd4ab4bb699d4e0d2ff8f113d612a30e67dc6237bbf6a9d1aa8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.7-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 545.8 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.7-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 81311415bf501e1bf3b30b278718fb4ee9ea3ceea082290e3f55a75de7614f09
MD5 6161c3aee21b22a53aed45fef05283cb
BLAKE2b-256 88f2354fb1b35452a66799a15b2a50c7011486e7d9f3be0672f3ff0f66dc4a81

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.7-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9588be3e7ffe4dcf66ba914162718223b6833f53c9ccdc6f9bbd7b1a196e4d38
MD5 ab0d6baadb1dcad262ca8a6cc5bf9a0a
BLAKE2b-256 bb0bbb129461d695877b48cd1a1419d0dbcaaf52b339ee65b25f7062a53f091b

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.7-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.7-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.7-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 fb67466d2f8576c836fa49ea08dd118d040c8df020663b6983a971889458c442
MD5 86710ea2955d71fb2af08b0eb4e2f350
BLAKE2b-256 1a60fc87b55ba4f1de15ff5fa62e926026a665de8c1c43247130760e9e8b5840

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.7-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 549.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.7.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e4d73ab8458c816ddcd889b9c28a2b9ce1449fc37864f71b5ce01e9a22c2455b
MD5 6edac1a52b1520697b6a64168d1eb632
BLAKE2b-256 c9c43513fa19de89353aa6d572b6388ccbe5d64910d8e5a95e1977aacc7bf7df

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1ed9b47ea75254ad9c0adced82597bcc01d5d2ebf6544b2ac28b84fcc6906c20
MD5 8f4409efbac2dfeb196e6e6ba4459faa
BLAKE2b-256 1ffd913153e51bc97488e64c863dbb38f3838b76378703d1693a3f796c68e534

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.7-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.7-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.7-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 f4df2aff5dd4d45a566f63f8600a7f1d8fcc835ba6e0f4183b1aa2fdbac52d0e
MD5 170cc42485fec12ac2a62fe049150b07
BLAKE2b-256 b5b6705b444126b655fd98bddea647962a679494984c318491884db4579bd05f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 549.5 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.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c3095407e26ba37df215e4ce9f7f6b885fa53db7f905b5f8e42164f40c7a2405
MD5 c37c4e65bb0dd3442f4069ae623ac95b
BLAKE2b-256 0478a490df0d82ae41cf4a442c831221d38f54e889cc849f64b5ef23d9cde13a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea4b4cebfa0971fcb40fee9ca1b996f1a671312f9e3ed9d65135e1d9483f37f6
MD5 b52e9cb729be92c34ef624c482d30269
BLAKE2b-256 251381c9a2185c2932b54af022839fb8757f2a788511286c8ad6d39535e91918

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.7-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.7-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.7-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 55b2dae275e87e697ba826a64f137375e0ff34a688d805701a156417fc7a0ce0
MD5 1a7097a6de4df4ff3d32166845d3130b
BLAKE2b-256 fbf614bb4b6e90ac1bc196d375d82f02ce93bc401006785e5a84a91526d53869

See more details on using hashes here.

Provenance

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