pjson-rs
SIMD-accelerated (AVX2 / SSE2 / ARM64 NEON) streaming partial JSON parser for Python — a zero-dependency Rust/PyO3 drop-in replacement for partial-json-parser plus a stateful $O(N)$ StreamParser, built for LLM tool-call streaming (vLLM, SGLang, LangChain, and AI agents).
- 14×–16× faster single-shot
loads/raw_decodevspartial-json-parser - 100×–330× faster stateful $O(N)$ streaming (
StreamParser.complete()) on 1 KB–8 KB chunked streams - Drop-in
Allowbitflags (1:1 withpartial_json_parser.core.options.Allow) - Single-pass
raw_decode(s, allow) -> (obj, end_char_idx)— handles trailing data & Unicode char offsets without catchingJSONDecodeError - Pythonic
cp39-abi3wheel (~270 KB, works on Python 3.9–3.14+, free-threaded ready withgil_used = false) - Accepts
str | bytes | bytearray(including multi-byte UTF-8 split acrossbyteschunks inStreamParser.feed) - Uniform
json.JSONDecodeError— never leaksAssertionError,IndexError, or lone UTF-16 surrogates
Install
pip install pjson-rs
Quick Start
Drop-in partial-json-parser & vLLM/SGLang raw_decode
import pjson_rs
from pjson_rs import Allow
# Drop-in replacement for partial_json_parser.loads
obj = pjson_rs.loads('{"tool": "write_file", "path": "src/main.rs", "content": "fn main', Allow.ALL)
# {'tool': 'write_file', 'path': 'src/main.rs', 'content': 'fn main'}
# Single-pass raw_decode with trailing text & exact Python char offset
text = '{"emoji": "🚀", "n": 42} trailing text'
obj, end_idx = pjson_rs.raw_decode(text, Allow.ALL)
assert text[end_idx:] == " trailing text"
Stateful $O(N)$ StreamParser
import pjson_rs
sp = pjson_rs.StreamParser()
for chunk in [b'{"cmd": "echo ', b'\xf0\x9f', b'\x9a\x80", "ok": tr', b'ue}']:
sp.feed(chunk)
healed_json = sp.complete() # O(1) close, always valid UTF-8 JSON
assert sp.done()
assert sp.loads() == {"cmd": "echo 🚀", "ok": True}
sp.reset() # reuse internal buffers across tool calls
Benchmarks
8-byte chunk streaming and 75%-truncated single-shot loads (benchmarks/bench.py):
| Workload | partial-json-parser |
pjson_rs (Intel i5-12400 AVX2) |
pjson_rs (Apple M4 NEON) |
|---|---|---|---|
Single-shot 1 KB |
30.0 µs (x86) / 26.5 µs (M4) |
2.1 µs (14.4×) |
1.7 µs (15.3×) |
Single-shot 8 KB |
200.8 µs (x86) / 129.9 µs (M4) |
14.5 µs (13.9×) |
10.9 µs (11.9×) |
Single-shot 32 KB |
817.2 µs (x86) / 605.1 µs (M4) |
49.5 µs (16.5×) |
43.3 µs (14.0×) |
Streaming 1 KB (139 × 8B) |
3.56 ms (x86) / 2.16 ms (M4) |
0.25 ms (raw_decode, 14.2×) · 0.02 ms (StreamParser, 162×) |
0.18 ms (12.0×) · 0.02 ms (108×) |
Streaming 8 KB (1,041 × 8B) |
130.5 ms (x86) / 91.8 ms (M4) |
9.46 ms (raw_decode, 13.8×) · 0.39 ms (StreamParser, 333×) |
8.25 ms (11.1×) · 0.31 ms (298×) |
ABI & Verification
cp39-abi3Limited API verified withabi3audit --strict- PEP 561 typed (
py.typed+__init__.pyi) verified withmypy --strictandstubtest - Rust SIMD alignment tests (
cargo test --lib) across AVX2, SSE2, and ARM64 NEON - Differential property-based testing (
hypothesis), split-UTF-8, 8-thread concurrency, andtracemallocleak tests
License
MIT
Metadata
Release files for pjson-rs 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pjson_rs-0.1.0.tar.gz | 21.2 kB | With provenance | Details for pjson_rs-0.1.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| pjson_rs-0.1.0-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for pjson_rs-0.1.0-cp39-abi3-win_amd64.whl |
| pjson_rs-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details for pjson_rs-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| pjson_rs-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details for pjson_rs-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| pjson_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for pjson_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl |
| pjson_rs-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details for pjson_rs-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl |
Total release size: 1.3 MB
Release files / pjson_rs-0.1.0.tar.gz
| Download URL | pjson_rs-0.1.0.tar.gz |
|---|---|
| Size | 21.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
375764fe5b7c62d3ad28111aff4be4cdd8950afd2478d0e407af24f1ea252a05
|
|
BLAKE2b-256 checksum How to use checksums |
d5e78d8f0db0486c58331b82f36e11f32c540ab413d97af23dfba88d0146f480
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / pjson_rs-0.1.0-cp39-abi3-win_amd64.whl
| Download URL | pjson_rs-0.1.0-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 171.7 kB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
e77eafb3e373f240389ab3d09b5d75bfbad54258176dda836adff21b7acdfbe5
|
|
BLAKE2b-256 checksum How to use checksums |
6e115848ec294fa998ff21cbe05e78920c03db4da5f73651399930557e625aaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / pjson_rs-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | pjson_rs-0.1.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 290.1 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b5945a9575f835f9931d76ec30f98d0d567d0a58459d12b49a295c017500c082
|
|
BLAKE2b-256 checksum How to use checksums |
880364013babdacfb8a42aa06b2668c36617e502708f31030f38cb318b2cc75a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / pjson_rs-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | pjson_rs-0.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 289.0 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
8e7b0c3b5d86a3d8c955055431cafa7940296513f7f7e8c18d91a883502aafc8
|
|
BLAKE2b-256 checksum How to use checksums |
803140832cb5e993f402bdf6cb1682c9a1be33dfc702df581c87a9286b0f0521
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / pjson_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | pjson_rs-0.1.0-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 262.2 kB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2506286f905eab48ad584c36bdb9aeab6c7ac644e53ae27189c8ac8cdee767d8
|
|
BLAKE2b-256 checksum How to use checksums |
d9559b3e86acb2ef2b25ac790379ef1d69684d5deec98c1d3945d3769a991c64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / pjson_rs-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | pjson_rs-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 269.7 kB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
9e52ec63c5c0e446ab8c1a2c7d5fd152f157e12b356b93d9ac77f06a2dcdf9ba
|
|
BLAKE2b-256 checksum How to use checksums |
60ce600eb9eeda26cbee4ad10389faccd598bbd1cbbc8c979de937bc5cbf2d32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for pjson-rs 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for pjson_rs-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.