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.0.tar.gz (210.5 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.0-cp314-cp314-win_amd64.whl (538.0 kB view details)

Uploaded CPython 3.14Windows x86-64

yarutsk-0.6.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (659.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

yarutsk-0.6.0-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.0-cp313-cp313-win_amd64.whl (544.1 kB view details)

Uploaded CPython 3.13Windows x86-64

yarutsk-0.6.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (665.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

yarutsk-0.6.0-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.0-cp312-cp312-win_amd64.whl (544.6 kB view details)

Uploaded CPython 3.12Windows x86-64

yarutsk-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (666.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

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

File metadata

  • Download URL: yarutsk-0.6.0.tar.gz
  • Upload date:
  • Size: 210.5 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.0.tar.gz
Algorithm Hash digest
SHA256 652ceb0668591166fe61080605ca84b0ca6e6048be74f10ad6b8e322b3dd273d
MD5 854b6c3125cda7416a28e925c7baf92f
BLAKE2b-256 51736b76b257ebf9e582022442c8304951b242fa7eb043238e2db5c7b611ff8f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 538.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.6.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 0728c019f3c14a20b9334bb8644152795a42d91d45b43d044062a2b13c52f580
MD5 a7eb91a5c2de843ad8f39526736779cc
BLAKE2b-256 c6d64736d28918e8b8112bd3f1d20468061148352ed09711d152ecb6f57752f1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 91ed60c2f7e85dc8beddaea101a8eb6ba0fb49fcab6f3fec0e030da07b7807a2
MD5 0b9e816bb9589417a7061534e4924797
BLAKE2b-256 0682ab248b0d4d7c2f2f83b2c3a9a9fcc869d71d7c7365e570214d7a406ea363

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.0-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.0-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.0-cp314-cp314-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 57c0b4751076d8fa3325dd64692f06a1cba9ec0d77393c136b0d6ef94c77495b
MD5 b8fc37f553008f1fe69c0aea61613466
BLAKE2b-256 abdba363631a4256aa523b01bbfeef753a05b9a30718fc061ca53add22383fb6

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 544.1 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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1455b4cdc0fee500963ba84b9b52895a21e454fe77bc258dc4b7ab2df36ee786
MD5 21c8f7b8c56d4fd929f02f981523bde1
BLAKE2b-256 fd5d4c78da2e85d50f50a7066c86d1676de280c22239aba8ecf2b6c91dbb48e3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b52d70fb9d612c5a4ea3a029be12636d28b169919fedbd2c3f30d939d0a39b3e
MD5 19775c5c00598832d9c994d7bb6114b9
BLAKE2b-256 4f01ee9bce77636e9fb43037ee9dc40655652ede75166cf238a126015bae9d1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.0-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.0-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.0-cp313-cp313-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 43fe79ab568ff12ac7e77c349291465495c185298382a01b7508652707ec66cb
MD5 11d07e14f65c8c3623b20515a8123ffb
BLAKE2b-256 c5db51f855a711d6f40999ccb7a272803772a2cfa29d10368c1ec7811a6e8c7f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: yarutsk-0.6.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 544.6 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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 94bc80ebca5b142d7abe4255eee61145ef260258fa5276cd32494c36a5350c05
MD5 9c63f8ecbc7c3ea389a6eabd7cea45b0
BLAKE2b-256 6299dd47fecddce8bcd07b1f00f96ab94ad972c2310a80bf678d8f206e7d0b36

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for yarutsk-0.6.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e174c5bd57bef15067d6f435f578061dab0e70d1a58ee5add721aff2186432d2
MD5 b9e81de73f0b105c966678991d7ae733
BLAKE2b-256 cb3aab5e234a0b1f178d086205ad732a5f81d2427d470b5b0ef17fbac6027302

See more details on using hashes here.

Provenance

The following attestation bundles were made for yarutsk-0.6.0-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.0-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.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 fbe0253df6831b7df81e3bfd4b2530469eedd402a48df3a264d237e16b6ec6a4
MD5 84e1a491bad6817bfe84212fd6e2313f
BLAKE2b-256 87794ab55cf78216f32ce38f1ba56b81651786e38cadceb7c93619476e09b550

See more details on using hashes here.

Provenance

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