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

Uploaded CPython 3.14Windows x86-64

yarutsk-0.7.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (673.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.7.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.7.3-cp313-cp313-win_amd64.whl (553.8 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.7.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (677.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.7.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.7.3-cp312-cp312-win_amd64.whl (554.4 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.7.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (678.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

File metadata

  • Download URL: yarutsk-0.7.3.tar.gz
  • Upload date:
  • Size: 228.7 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.3.tar.gz
Algorithm Hash digest
SHA256 e27d5ffc9335888bcd527fd29c028dbaf1b52abf52eaa41b43e046f00b1842aa
MD5 689ad37d208729b4a092cffe0509ab7b
BLAKE2b-256 aadd3b7a39d7aa893b27a2ef4d5c154c799489e576a3de33ff953081dbe1784f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.3-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 550.3 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.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b52cd1dc471e2a6de17cd5897785dfa4053a2d92f2269566a4621c398b5ca762
MD5 89e375fc2bb7a5b90d9e36262231c40d
BLAKE2b-256 c7841ef26c091dd12e743c51eab80491d6b9786184b0da35cce55154c6f94e7d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4952cfd31108e98421c4892fdba90b51dbe7c745fd4a855c19897cd58e74515c
MD5 9616621c6cbbd9013cf4599d8f93f24f
BLAKE2b-256 026f2664b3d88f3d16b509161da011af969fd7bc36f7f7d245df0924b47f95e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.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.7.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.7.3-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 e54d70971867219cbaeea75a2bccf0c6a96768082ad0b687d297bdf9b3a7d7f2
MD5 4748bdb6134678a51c366f017f3febd6
BLAKE2b-256 8050776cc57ea9e9c303a52e0a6e58746996234a441bd5f02d0cdfd87d36e40c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 553.8 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f5f7b7f9bf5a413b5f5925f484d4ffc241cb347c84dc5fafacbec9a4087c5f74
MD5 d7b8f932a7553633aa6a255a925a101b
BLAKE2b-256 81492ac5feb9227724454bed1f12fc20e5baf1da5c09d00cba809408c843fedf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c50a675770649971f8caf9c528c72cd24e1b016495667c31fc4cb70211f4fdcd
MD5 c950a8e05a839e80f3d9db43fa9973e7
BLAKE2b-256 56659fec325aed516b342fa3ffb8f96b7f1b9a4a5fb9f13cc61c0805f02da05d

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.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.7.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.7.3-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 5efaa9e753da72157b57598219e242a8b26c765fa088d0ea9c92134bfe0665e5
MD5 db031973b5cfd4cae23f8bfe1064f69a
BLAKE2b-256 a1b62c7a83d9defaf4569ed25dfe18361aedd0c3fec20c466ed230a5bac073b0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.7.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 554.4 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 17ef62539baa54f33c8f726a12880c3962bc94cb975a0da674f5ea9a1a24d5d1
MD5 94ea1397c1c7e02eec5423db06465fe2
BLAKE2b-256 7d63a4242c87820a2798180622e6a6a76a0590f7bceca2791aa3170600281ce7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.7.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb164d0dab40cebd0e397e81cf23b9bdd1d06ab1e718bcb1fe8b91b05602a2c1
MD5 3a185e599ec76bae4284b4fac55e4745
BLAKE2b-256 ce9dd827be322825fd03bdfdd880c02125cf913e8021dbc2bd0ae40fdcbe8631

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.7.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.7.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.7.3-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 2b6b825cce62e888d3f55091bdfebc2b9a5d3920f8bcf0a38a655bd6fa283ef0
MD5 e6d3384128d0f4ff135221bbad625f07
BLAKE2b-256 d5f501c2b57a9692723a3e3f988d84f7275e86a53101dc864138de9a6ad10035

See more details on using hashes here.

Provenance

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