yeptris — YAML for Python at libleptris speed
An FFI-based (no C extension) YAML library over libyeptris — the YAML counterpart of libleptris. PyYAML-compatible semantics, one shared library, zero compilation at install.
Install (development)
# the sibling C checkout: ~/src/leptris/yeptris
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DYEPTRIS_BUILD_SHARED=ON
cmake --build build
cd ~/src/leptris/yeptris-py
YEPTRIS_LIB_PATH=../yeptris/build/src/libyeptris.dylib python3 -m pytest
Without YEPTRIS_LIB_PATH the loader falls back to a vendored
yeptris/_platform/<tag>/ copy, then to the sibling checkout's
build directory. Any libyeptris.{so,dylib,dll} path works.
Usage
import yeptris
from yeptris import yaml # PyYAML-compatible surface
yaml.safe_load("name: yeptris\nrating: 10\n")
# {'name': 'yeptris', 'rating': 10}
yaml.safe_load_all("--- 1\n--- two\n") # [1, 'two']
yaml.safe_dump({"b": 2, "a": [1, "x"]}) # 'a:\n - 1\n - x\nb: 2\n'
yeptris.load("k: v") # the neutral surface
yeptris.dump({"k": [1, 2]})
Typing follows PyYAML's SafeLoader (YAML 1.1 implicit typing):
yes/no/on/off booleans, 0x/leading-0/0b/sexagesimal integers,
dot-required floats, timestamps with offsets, merge keys, anchor
identity. Every deliberate divergence is pinned by a test.
Design
One parse, one bulk drain: the record array and string arena are
read in two FFI calls, then a pure-Python walk over the unpacked
records — the FFI tax is O(1) per document, never per event (the
same seam yeptris-ruby rides). The 36-byte record layout is
ABI-pinned in the C header and mirrored in _ffi.py.
Performance
python3 bench.py — same-process comparison against PyYAML (pure)
and CSafeLoader/CDumper (libyaml C extensions):
- load: 28-39x PyYAML pure, 3.8-6.1x CSafeLoader
- dump: ~1.7x PyYAML pure, ~2x behind CDumper (which walks the
tree entirely in C — a no-C-extension design's ceiling is the
Python walk itself; the tree raises through ONE
yeptris_document_buildcall)
Both directions are O(chunks) in FFI calls: loads drain records in two calls, dumps build through one flat entry array.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 yeptris-0.1.1.0.tar.gz.
File metadata
- Download URL: yeptris-0.1.1.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
108ac5a910b2323007aea1d3d5c1ae6bbbe676fd0caee2b845b1b995d1bf95ea
|
|
| MD5 |
e210159e17de5132ba36a814eeac99ac
|
|
| BLAKE2b-256 |
b8bd47f9a9de297447b3ad31a8847a51892c59d1ac50a7d86cf8689a0c32a011
|
File details
Details for the file yeptris-0.1.1.0-py3-none-any.whl.
File metadata
- Download URL: yeptris-0.1.1.0-py3-none-any.whl
- Upload date:
- Size: 12.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cd5d33ba47b60afeebe580a044e6aa8d3428f524892265abf2ffdc1ca866d90
|
|
| MD5 |
bb213a3064cc5b89c426faa14f08e131
|
|
| BLAKE2b-256 |
ba7dace19fb0c7c9280742be517063a45e3c74a8b2b11be9230985c5a8c6535d
|