All Projects → Iotic-Labs → py-lz4framed

Iotic-Labs / py-lz4framed

Licence: Apache-2.0 license
LZ4-frame library for Python (via C bindings)

Programming Languages

c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to py-lz4framed

pyrus-cramjam
Thin Python wrapper to de/compression algorithms in Rust - lightweight & no dependencies
Stars: ✭ 40 (-4.76%)
Mutual labels:  compression, lz4
blz4
Example of LZ4 compression with optimal parsing using BriefLZ algorithms
Stars: ✭ 24 (-42.86%)
Mutual labels:  compression, lz4
tiny
compress data for better performance
Stars: ✭ 21 (-50%)
Mutual labels:  compression, lz4
lz4-napi
Fastest lz4 compression library in Node.js, powered by napi-rs and lz4-flex.
Stars: ✭ 29 (-30.95%)
Mutual labels:  compression, lz4
smallz4
Optimal LZ4 compression
Stars: ✭ 24 (-42.86%)
Mutual labels:  compression, lz4
Lz4
Extremely Fast Compression algorithm
Stars: ✭ 6,623 (+15669.05%)
Mutual labels:  compression, lz4
EasyCompressor
⚡ A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.
Stars: ✭ 167 (+297.62%)
Mutual labels:  compression, lz4
lz4ultra
Optimal LZ4 compressor, that produces files that decompress faster while keeping the best compression ratio
Stars: ✭ 49 (+16.67%)
Mutual labels:  compression, lz4
Guetzling
Guetzling is a simple script for macOS and Linux written in Bash, to automate (recursively finding files) the compression of jpegs using the Guetzli algorithm.
Stars: ✭ 20 (-52.38%)
Mutual labels:  compression
xcdat
Fast compressed trie dictionary library
Stars: ✭ 51 (+21.43%)
Mutual labels:  compression
roadroller
Roadroller: Flattens Your JavaScript Demo
Stars: ✭ 253 (+502.38%)
Mutual labels:  compression
php-closure-compiler
A PHP Library to use Google Closure Compiler compress Javascript
Stars: ✭ 20 (-52.38%)
Mutual labels:  compression
RC-PyTorch
PyTorch code for the CVPR'20 paper "Learning Better Lossless Compression Using Lossy Compression"
Stars: ✭ 44 (+4.76%)
Mutual labels:  compression
FrameOfReference
C++ library to pack and unpack vectors of integers having a small range of values using a technique called Frame of Reference
Stars: ✭ 36 (-14.29%)
Mutual labels:  compression
FastIntegerCompression.js
Fast integer compression library in JavaScript
Stars: ✭ 46 (+9.52%)
Mutual labels:  compression
pybashutils
Collection of Bash and Python scripts I've made that may be generally useful
Stars: ✭ 26 (-38.1%)
Mutual labels:  compression
GenuineChannels
Collection of custom .NET Remoting channels
Stars: ✭ 29 (-30.95%)
Mutual labels:  compression
ZRA
ZStandard Random Access (ZRA) allows random access inside an archive compressed using ZStandard
Stars: ✭ 21 (-50%)
Mutual labels:  compression
ruby-xz
Ruby bindings for liblzma, using fiddle
Stars: ✭ 33 (-21.43%)
Mutual labels:  compression
GainedVAE
A Pytorch Implementation of a continuously rate adjustable learned image compression framework.
Stars: ✭ 43 (+2.38%)
Mutual labels:  compression

Overview

This is an LZ4-frame compression library for Python v3.2+ (and 2.7+), bound to Yann Collet's LZ4 C implementation.

Installing / packaging

# To get from PyPI
pip3 install py-lz4framed

# To only build extension modules inline (e.g. in repository)
python3 setup.py build_ext -i

# To build & install globally
python3 setup.py install

Notes

Usage

Single-function operation:

import lz4framed

compressed = lz4framed.compress(b'binary data')

uncompressed = lz4framed.decompress(compressed)

To iteratively compress (to a file or e.g. BytesIO instance):

with open('myFile', 'wb') as f:
    # Context automatically finalises frame on completion, unless an exception occurs
    with Compressor(f) as c:
        try:
            while (...):
               c.update(moreData)
        except Lz4FramedNoDataError:
            pass

To decompress from a file-like object:

with open('myFile', 'rb') as f:
    try:
        for chunk in Decompressor(f):
           decoded.append(chunk)
    except Lz4FramedNoDataError:
        # Compress frame data incomplete - error case
        ...

See also lz4framed/__main__.py for example usage.

Documentation

import lz4framed
print(lz4framed.__version__, lz4framed.LZ4_VERSION, lz4framed.LZ4F_VERSION)
help(lz4framed)

Command-line utility

python3 -mlz4framed
USAGE: lz4framed (compress|decompress) (INFILE|-) [OUTFILE]

(De)compresses an lz4 frame. Input is read from INFILE unless set to '-', in
which case stdin is used. If OUTFILE is not specified, output goes to stdout.

Tests

Static

This library has been checked using flake8 and pylint, using a modified configuration - see pylint.rc and flake8.cfg.

Unit

python3 -m unittest discover -v .

Why?

The only existing lz4-frame interoperable implementation I was aware of at the time of writing (lz4tools) had the following limitations:

  • Incomplete implementation in terms of e.g. reference & memory leaks on failure
  • Lack of unit tests
  • Not thread safe
  • Does not release GIL during low level (de)compression operations
  • Did not address the requirements for an external project
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].