jiter-pupy: Pure Python jiter Implementation
A drop-in replacement for the jiter package that is API-compatible with the original Rust-based implementation, but uses only Python's standard library json module.
Features
- 100% API compatible with the Rust-based jiter package
- Pure Python implementation using only the standard library
- No compilation required - works anywhere Python runs
- Supports all jiter features:
- String caching for performance
- Partial JSON parsing
- Different float modes (float, decimal, lossless-float)
- Special value handling (Infinity, NaN)
- Duplicate key detection
Installation
pip install jiter-pupy
Usage
import jiter_pupy as jiter
# Parse JSON data
data = jiter.from_json(b'{"name": "John", "age": 30}')
print(data) # {'name': 'John', 'age': 30}
# Use different float modes
from decimal import Decimal
data = jiter.from_json(b'{"value": 123.456}', float_mode="decimal")
print(isinstance(data["value"], Decimal)) # True
# Handle partial JSON
incomplete = b'{"name": "John", "address": {"city": "New Yor'
data = jiter.from_json(incomplete, partial_mode=True)
print(data) # {'name': 'John'}
# Include trailing strings
data = jiter.from_json(incomplete, partial_mode="trailing-strings")
print(data) # {'name': 'John', 'address': {'city': 'New Yor'}}
# Catch duplicate keys
try:
jiter.from_json(b'{"foo": 1, "foo": 2}', catch_duplicate_keys=True)
except ValueError as e:
print(e) # Detected duplicate key "foo" at line 1 column 18
# String caching
jiter.cache_clear()
jiter.from_json(b'{"foo": "bar"}')
print(jiter.cache_usage() > 0) # True
API
def from_json(
json_data: bytes,
/,
*,
allow_inf_nan: bool = True,
cache_mode: Literal[True, False, "all", "keys", "none"] = "all",
partial_mode: Literal[True, False, "off", "on", "trailing-strings"] = False,
catch_duplicate_keys: bool = False,
float_mode: Literal["float", "decimal", "lossless-float"] = "float",
) -> Any:
"""Parse input bytes into a JSON object."""
def cache_clear() -> None:
"""Reset the string cache."""
def cache_usage() -> int:
"""Get the size of the string cache in bytes."""
class LosslessFloat:
"""Represents a float from JSON, preserving the exact string representation."""
Performance
While this implementation prioritizes API compatibility over raw performance, it still offers benefits:
- String caching can improve performance in scenarios with repeated strings
- No compilation required, works anywhere Python runs
- Useful as a fallback when the compiled jiter package isn't available
Development
This project uses Hatch for development workflow management.
Setup Development Environment
# Install hatch if you haven't already
pip install hatch
# Create and activate development environment
hatch shell
# Run tests
hatch run test
# Run tests with coverage
hatch run test-cov
# Run benchmarks
hatch run bench
# Run linting
hatch run lint
# Format code
hatch run fix
License
MIT License
Metadata
Release files for jiter-pupy 0.8.5
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 |
|---|---|---|---|---|
| jiter_pupy-0.8.5.tar.gz | 97.4 kB | Without provenance | Details for jiter_pupy-0.8.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jiter_pupy-0.8.5-py3-none-any.whl | Python 3 | none | any | Details for jiter_pupy-0.8.5-py3-none-any.whl |
Total release size: 105.7 kB
Release files / jiter_pupy-0.8.5.tar.gz
| Download URL | jiter_pupy-0.8.5.tar.gz |
|---|---|
| Size | 97.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3ff01e69d512120d71f9fe08b3adb89e8af5e6b0bce6a8bc8ab87ae8b72490e
|
|
BLAKE2b-256 checksum How to use checksums |
31f5558310da9315cc56846282284203034e97c6bde570eb9275f7ac1635337f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.4
|
Release files / jiter_pupy-0.8.5-py3-none-any.whl
| Download URL | jiter_pupy-0.8.5-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e3ebe106f45e8bb5b5c192f03bb8f01b4001f3b1837058f43452ccb2f2f0f06
|
|
BLAKE2b-256 checksum How to use checksums |
96d483f699efc1febcf5115656280d3ec6c858f410674584b117675f6c88c169
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.4
|
Security for jiter-pupy 0.8.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.