Skip to content

v0.1.3 — Const generic delimiter dispatch (~4% Rust perf)

Choose a tag to compare

@github-actions github-actions released this 05 Apr 15:02
· 25 commits to main since this release

Highlights

Pure performance release: ~4% faster Rust encoder via const-generic monomorphization on the delimiter byte. Python users see no user-visible change; Rust library users benefit directly.

Changes

Const generic delimiter dispatch

The encoder's hot path is now monomorphized over const DELIM: u8:

pub fn encode_with(json_bytes: &[u8], cfg: &Config) -> Result<String, String> {
    match cfg.delimiter {
        b',' => write_root::<b','>(&value, cfg, &mut out),
        b'\t' => write_root::<b'\t'>(&value, cfg, &mut out),
        b'|' => write_root::<b'|'>(&value, cfg, &mut out),
        _ => return Err(...),
    }
    ...
}

With delimiter as a compile-time constant:

  • The DELIM != b',' check in the [N] array header emit folds away when DELIM=','
  • out.push(DELIM as char) in tight per-value separator loops becomes a direct byte store (no register load)
  • b == DELIM in value_needs_quoting merges with existing match arm for the default delimiter

Performance

Metric v0.1.2 v0.1.3
Pure Rust (neptune 50-doc) 12.55 μs 12.10 μs
Python in-process 15.0 μs 15.4 μs (within noise)

4% gain on the Rust side. On Python, the orjson.dumps (~3μs) + PyO3 boundary crossings dilute the improvement into measurement noise.

No API changes

All 146 spec fixtures pass unchanged. Drop-in replacement for v0.1.2.

Install

pip install --upgrade etoon                # Python
cargo update -p etoon                      # Rust library
cargo install --force etoon --no-default-features  # Rust CLI rebuild

Full Changelog: v0.1.2...v0.1.3