Skip to main content

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

Python API

from jzpack import compress, decompress

data = [{"service": "api", "status": "ok", "latency": 42} for _ in range(10000)]
compressed = compress(data)

original = decompress(compressed)

With Compression Level

from jzpack import compress

compressed = compress(data, level=19)

Using the Compressor Class

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")

Streaming for Large Datasets

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

jzpack achieves superior compression through:

  1. Schema Detection - Groups records by structure
  2. Column-Oriented Storage - Stores each field as a column
  3. Smart Encoding Selection per column:
    • RLE for constant/repetitive values (timestamps, status codes)
    • Delta for sequential numbers (IDs, counters)
    • Dictionary for low-cardinality strings (service names, log levels)
  4. Binary Serialization via MessagePack (eliminates JSON overhead)
  5. Zstandard Compression (better ratio than GZIP at same speed)

API Reference

Functions

Function Description
compress(data, level=3) Compress list of dicts to bytes
decompress(data) Decompress bytes to list of dicts

Classes

Class Description
JZPackCompressor Main compressor with compress(), decompress(), compress_to_file(), and decompress_from_file() methods
StreamingCompressor Add records incrementally with add_record() or add_batch(), then finalize()

Development

git clone https://github.com/hasanzaibak/jzpack.git
cd jzpack

pip install -e ".[dev]"

pytest

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

jzpack-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

jzpack-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file jzpack-0.1.0.tar.gz.

File metadata

  • Download URL: jzpack-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jzpack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9e4d5b2de1933b4a00b8c7f37cdf262e5c7f16879104154c443c52dfaf9bd1f0
MD5 7944100cf6bf496ee3cce17866a0d92a
BLAKE2b-256 d8bbe8384262393c9a001f985dbbf0fa7e98c1b6323d8631e8eff05168a54316

See more details on using hashes here.

Provenance

The following attestation bundles were made for jzpack-0.1.0.tar.gz:

Publisher: python-publish.yml on hasanzaibak/jzpack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jzpack-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jzpack-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jzpack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48b9c919cc2a7260bde825bd7e29fe0b3744011a0b953a119d8a3d33ce94b004
MD5 d7f4167a40c1542b18edce253a86fa37
BLAKE2b-256 83ed99401195497d395c0cf52fe6e989a682308ce114e13f1facee928c9e3cce

See more details on using hashes here.

Provenance

The following attestation bundles were made for jzpack-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on hasanzaibak/jzpack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page