A YAML 1.2 subset parser built for speed, written in Rust.
Project description
TurboYAML
Subset of YAML 1.2, built for parsing speed. A Rust parser with Rust and Python bindings.
Valid TurboYAML is always valid YAML 1.2. The reverse need not hold — so parse with TurboYAML and fall back to a full YAML parser when you hit something it deliberately doesn't support.
Why
TurboYAML tries to trade YAML's feature richness for speed, while keeping a useful featue set alive.
On typical config and data it parses roughly 25–50× faster than PyYAML's libyaml C extension, producing native Python objects (dict / list / str / int / float / bool / None) directly — no intermediate tree.
| Profile | turboyaml (Python) | PyYAML (libyaml) | speedup |
|---|---|---|---|
| Flat records | 11M lines/s | 360k lines/s | 31× |
| Deep tree | 3.9M lines/s | 99k lines/s | 39× |
| Inline flow collections | 1.7M lines/s | 32k lines/s | 53× |
| Block scalars | 6.9M lines/s | 210k lines/s | 33× |
Measured on one machine; reproduce with cargo run --release --features gen --bin perf_test && python perf_test.py.
Install
pip install rs-turboyaml
The PyPI distribution is rs-turboyaml; the import name is turboyaml.
Usage
Python
import turboyaml
obj = turboyaml.load(text) # → dict / list / str / int / float / bool / None
Catch UnsupportedFeatureError to fall back to a full parser when a document uses
something TurboYAML doesn't cover:
try:
obj = turboyaml.load(text)
except turboyaml.UnsupportedFeatureError:
import yaml
obj = yaml.safe_load(text)
Rust
let value = turboyaml::parse(input)?;
Supported
- Block mappings and sequences, arbitrarily nested
- Compact notation —
- key: value,- - nested - Scalar type inference:
null/~,True/False, integers (decimal /0x/0o), floats (incl..inf/.nan), strings - Double-quoted strings (single line, literal content)
- Flow collections —
[1, 2],{a: 1}— single-line, nestable - Block scalars —
|literal and>folded, with+/-chomping #comments- Any scalar type as a mapping key (
42:,True:,null:) - Optional duplicate-key rejection —
load(text, strict=True)/parse_strict
Notable differences from full YAML 1.2
- 2-space indentation only — no tabs, no other widths.
- Python-convention booleans:
True/Falseare bool; lowercasetrue/falseare strings (as are YAML 1.1'syes/no/on/off). - No escape sequences in quoted strings — content is literal UTF-8.
- One document per stream; UTF-8 only, no BOM.
Not supported
These raise a typed UnsupportedFeatureError — distinct from a malformed-input ParseError — so the fallback pattern above can recover them cleanly:
- Anchors and aliases —
&anchor,*alias - Tags —
!!str,!custom - Document markers (
---,...) and directives (%YAML) - Explicit block indentation indicators —
|2
Multi-document streams and multi-line quoted strings are also out of scope (for multi-line text, use a block scalar).
Status
Alpha. The base feature set plus block scalars are implemented and tested — including a differential fuzz of folding/chomping against PyYAML. YAML 1.1 boolean tokens are the one remaining roadmap item. See spec.md for the normative specification.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rs_turboyaml-0.1.0.tar.gz.
File metadata
- Download URL: rs_turboyaml-0.1.0.tar.gz
- Upload date:
- Size: 55.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc0687d653a09bcf4dde690d7b88aa78bca72a3eeeca8d90524cfd6e9e45db19
|
|
| MD5 |
f0c17f9302185d5fb61ddcdfaeedd17e
|
|
| BLAKE2b-256 |
cc980ccb8daf0d4133fa4a9b08406e2611349f2ec2b8652ab21156c770d73c40
|
File details
Details for the file rs_turboyaml-0.1.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: rs_turboyaml-0.1.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 617.8 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f72f4657349b431deb9806db06fb7ab3e1e35a64051b70ed359fd27a551b9205
|
|
| MD5 |
e0f9df5f2aa8be4ddce7667917857c80
|
|
| BLAKE2b-256 |
e1c032ca6cfde2226a8e029dcbd60ba6da19294ccae0964628b32d4afdc56e2e
|
File details
Details for the file rs_turboyaml-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rs_turboyaml-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 249.0 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d2e68ceaf1806a1e8d5085c9cb31b407b3e7f570c7381fbf4c9bed798592bfa
|
|
| MD5 |
34071bc26f4ba0fd038e73a453d4a161
|
|
| BLAKE2b-256 |
90573c3368ff7e9eccb0fe6a1634af2ec7941f1791316c0499022b03773eb944
|
File details
Details for the file rs_turboyaml-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rs_turboyaml-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 641.7 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4d8139b9bf80796d74c7b05d0b22e6bcb667f7bec48d5fa1ba476cc55c459fe
|
|
| MD5 |
62f1fa1e1b6c1318e51086cd38f3e186
|
|
| BLAKE2b-256 |
6040add3675162c400ca074a8bef213b9f86126c193c4fce9477f2353f16b351
|
File details
Details for the file rs_turboyaml-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rs_turboyaml-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 642.8 kB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a7b34324be3ab016714b92fac72be6da08e4b17b4692291d4a2be6bd8cf093f
|
|
| MD5 |
106c2a31e91ae77f781d030cb9a68cfa
|
|
| BLAKE2b-256 |
aeec8680b304a22235836a9de2843ab71c73077f491cae82db85d134544a6401
|