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

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

  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 repetitive values
    • Delta for sequential numbers
    • Dictionary for low-cardinality strings
  4. Binary Serialization via MessagePack
  5. 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

jzpack-0.1.1.tar.gz (9.2 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.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

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

Hashes for jzpack-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f433cde28d421f1d70fa305ff81bdf8da05b9fd851aac78d17b0eb1f9bc889c8
MD5 77ad9cd412fbe31be0d7ee33826a9e7a
BLAKE2b-256 063cc61afafadf32764f1319fbc8ded958313cea1cbe6d3f61cd3e3b77a2bffb

See more details on using hashes here.

Provenance

The following attestation bundles were made for jzpack-0.1.1.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.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

Hashes for jzpack-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0bc8ce3fd385fa7a9002f798c207095697dd710a93c574de7c787ad921cfac89
MD5 33acd5f411a1ca6d55da746fe7eef7df
BLAKE2b-256 a5ff36b10ad44bba78af80d45c48ac5ded266596367c411c2300e0bfe6dd5df8

See more details on using hashes here.

Provenance

The following attestation bundles were made for jzpack-0.1.1-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