Skip to main content
Documentation Status https://github.com/MacHu-GWU/compress-project/actions/workflows/main.yml/badge.svg https://codecov.io/gh/MacHu-GWU/compress-project/branch/main/graph/badge.svg https://img.shields.io/pypi/v/compress.svg https://img.shields.io/pypi/l/compress.svg https://img.shields.io/pypi/pyversions/compress.svg https://img.shields.io/badge/Release_History!--None.svg?style=social https://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social
https://img.shields.io/badge/Link-Document-blue.svg https://img.shields.io/badge/Link-API-blue.svg https://img.shields.io/badge/Link-Install-blue.svg https://img.shields.io/badge/Link-GitHub-blue.svg https://img.shields.io/badge/Link-Submit_Issue-blue.svg https://img.shields.io/badge/Link-Request_Feature-blue.svg https://img.shields.io/badge/Link-Download-blue.svg

Welcome to compress Documentation

https://compress.readthedocs.io/en/latest/_static/compress-logo.png

compress provides a unified interface for various mature data compression algorithms. It supports algorithms from both the Python Standard Library and the community, offering a range of options for different compression needs.

Supported Algorithms

From Python Standard library

From Community (Additional Library Required)

  • snappy, from Google, lower compression ratio but super fast! (on MacOS, you need to install it via brew install snappy, on Ubuntu, you need sudo apt-get install libsnappy-dev.

  • lz4, lower ratio, super fast!

  • pyzstd, very fast!

Note: Community libraries are not installed by default with compress. To include them, use:

pip install compress[lz4,snappy,zstd]

These libraries require a C compiler. If you encounter issues installing the C compiler for your OS, refer to this tutorial.

Usage Example

import sys
import compress.api as compress

data = ("hello world" * 1000).encode("utf-8")
print(f"before: {sys.getsizeof(data)}")

data_compressed = compress.compress(
    algo=compress.Algorithm.gzip,
    data=data,
    kwargs={"compresslevel": 9},
)
print(f"after: {sys.getsizeof(data_compressed)}")

Benchmark

This website provides comprehensive comparison and visualization. But how do you know how it works on your own production environment?.

compress comes with a tool to run benchmark test for All test case, All algorithm, All parameters, and you will get informative stats about ratio, compress/decompress speed in ascii table format. Then You are able to visualize it in the way you preferred.

To run benchmark test, just do:

pip install -r requirements-benchmark.txt
python ./benchmark/run_benchmark.py

Then you can find the result at benchmark/result.txt.

Install

compress is released on PyPI, so all you need is to:

$ pip install compress

To upgrade to latest version:

$ pip install --upgrade compress

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compress-0.1.1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

compress-0.1.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file compress-0.1.1.tar.gz.

File metadata

  • Download URL: compress-0.1.1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.10

File hashes

Hashes for compress-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2515acb17f3b276eff5be3a168598c1e59292fd546e020abfe7be53071a183d2
MD5 bd38bd38d73bff4506153dcf158c27e1
BLAKE2b-256 3f0d4ca2f7ec3f2261c0a4d788098beadf2b09b154b315383e5a26ff310c4525

See more details on using hashes here.

File details

Details for the file compress-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: compress-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.10

File hashes

Hashes for compress-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f5457d46581211c7336f0935d23e0ebc193ccb7e13b769ba646207e5734f5130
MD5 ad53105b7856e3c8edce7599d5be0934
BLAKE2b-256 d32c209d3ea9fcebabd01734c66be817950f8c97ea92469c51eaef8988691bfb

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

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