High-performance JSON/NDJSON compression library
Project description
jzpack
High-performance JSON/NDJSON compression library that significantly outperforms GZIP.
Features
- 83-99% smaller than GZIP on typical JSON log data
- Column-oriented storage with automatic schema detection
- Smart encoding selection per column (RLE, Delta, Dictionary)
- Zstandard compression with MessagePack serialization
- Streaming support for large datasets
- Type hints included
Benchmarks
Tested on 200,000 JSON records:
| Dataset | GZIP (level 9) | jzpack | Improvement |
|---|---|---|---|
| High-Cardinality Logs | 1.47 MB | 244 KB | 83.8% smaller |
| Mixed Service Logs | 1.72 MB | 99 KB | 94.4% smaller |
| Highly Repetitive Data | 175 KB | 579 B | 99.7% smaller |
Installation
pip install jzpack
Quick Start
from jzpack import compress, decompress
data = [{"service": "api", "status": "ok", "latency": 42} for _ in range(10000)]
compressed = compress(data)
original = decompress(compressed)
File I/O
import json
from jzpack import compress, decompress
# Compress JSON file
with open("data.json", "r", encoding="utf-8") as f:
data = json.load(f)
with open("data.jzpk", "wb") as f:
f.write(compress([data]))
# Decompress
with open("data.jzpk", "rb") as f:
data = decompress(f.read())[0]
Compression Level
from jzpack import compress
compressed = compress(data, level=19) # 1-22, higher = smaller but slower
Advanced Usage
JZPackCompressor
from jzpack import JZPackCompressor
compressor = JZPackCompressor(compression_level=3)
compressed = compressor.compress(data)
original = compressor.decompress(compressed)
compressor.compress_to_file(data, "output.jzpk")
data = compressor.decompress_from_file("output.jzpk")
StreamingCompressor
from jzpack import StreamingCompressor
compressor = StreamingCompressor(compression_level=3)
for record in records_iterator:
compressor.add_record(record)
compressor.add_batch(batch_of_records)
compressed = compressor.finalize()
compressor.clear()
How It Works
- Schema Detection - Groups records by structure
- Column-Oriented Storage - Stores each field as a column
- Smart Encoding Selection per column:
- RLE for repetitive values
- Delta for sequential numbers
- Dictionary for low-cardinality strings
- Binary Serialization via MessagePack
- Zstandard Compression
API Reference
| Function | Description |
|---|---|
compress(data, level=3) |
Compress list of dicts to bytes |
decompress(data) |
Decompress bytes to list of dicts |
License
MIT
Project details
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 jzpack-0.1.1.tar.gz.
File metadata
- Download URL: jzpack-0.1.1.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f433cde28d421f1d70fa305ff81bdf8da05b9fd851aac78d17b0eb1f9bc889c8
|
|
| MD5 |
77ad9cd412fbe31be0d7ee33826a9e7a
|
|
| BLAKE2b-256 |
063cc61afafadf32764f1319fbc8ded958313cea1cbe6d3f61cd3e3b77a2bffb
|
Provenance
The following attestation bundles were made for jzpack-0.1.1.tar.gz:
Publisher:
python-publish.yml on hasanzaibak/jzpack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jzpack-0.1.1.tar.gz -
Subject digest:
f433cde28d421f1d70fa305ff81bdf8da05b9fd851aac78d17b0eb1f9bc889c8 - Sigstore transparency entry: 780521905
- Sigstore integration time:
-
Permalink:
hasanzaibak/jzpack@1494481aacdde551babda73f8dd6b11ac411b496 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/hasanzaibak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@1494481aacdde551babda73f8dd6b11ac411b496 -
Trigger Event:
release
-
Statement type:
File details
Details for the file jzpack-0.1.1-py3-none-any.whl.
File metadata
- Download URL: jzpack-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bc8ce3fd385fa7a9002f798c207095697dd710a93c574de7c787ad921cfac89
|
|
| MD5 |
33acd5f411a1ca6d55da746fe7eef7df
|
|
| BLAKE2b-256 |
a5ff36b10ad44bba78af80d45c48ac5ded266596367c411c2300e0bfe6dd5df8
|
Provenance
The following attestation bundles were made for jzpack-0.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on hasanzaibak/jzpack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jzpack-0.1.1-py3-none-any.whl -
Subject digest:
0bc8ce3fd385fa7a9002f798c207095697dd710a93c574de7c787ad921cfac89 - Sigstore transparency entry: 780521906
- Sigstore integration time:
-
Permalink:
hasanzaibak/jzpack@1494481aacdde551babda73f8dd6b11ac411b496 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/hasanzaibak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@1494481aacdde551babda73f8dd6b11ac411b496 -
Trigger Event:
release
-
Statement type: