Skip to main content

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_build call)

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

yeptris-0.1.2.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yeptris-0.1.2.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file yeptris-0.1.2.0.tar.gz.

File metadata

  • Download URL: yeptris-0.1.2.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.5

File hashes

Hashes for yeptris-0.1.2.0.tar.gz
Algorithm Hash digest
SHA256 d1328ae8c5bbb432aa0c2a9d2282d21de54122f2efb901436f9b7a770882f3cb
MD5 ca71eca4c6ce001410b62d35ba0c105c
BLAKE2b-256 0e0711b2ea7f589e2d2660d943ca0f894ec61aa90526e698248e71abbd94f0cb

See more details on using hashes here.

File details

Details for the file yeptris-0.1.2.0-py3-none-any.whl.

File metadata

  • Download URL: yeptris-0.1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.5

File hashes

Hashes for yeptris-0.1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2a3cfdc030a401541eec9a2ae755a4802ee0aab3cb6dc5c26d25ecf286e998f
MD5 b5a9ff1f8dd26e41836d83ed7c3cd196
BLAKE2b-256 e974d8d2535fab59515a4bd61a26c5d62868e1996afb8caf2dffec3ebef441a3

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.10.1

2 files

0.1.10.0

2 files

0.1.9.1

2 files

0.1.9.0

2 files

0.1.8.0

2 files

0.1.7.0

2 files

0.1.5.0

2 files

0.1.4.0

2 files

0.1.3.0

2 files

0.1.2.1

2 files

This release

0.1.2.0 This release

2 files

0.1.1.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page