All Projects → milesgranger → pyrus-cramjam

milesgranger / pyrus-cramjam

Licence: MIT License
Thin Python wrapper to de/compression algorithms in Rust - lightweight & no dependencies

Programming Languages

rust
11053 projects
python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to pyrus-cramjam

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 (+317.5%)
Mutual labels:  compression, gzip, decompression, brotli, snappy, zstd, lz4, deflate
Archiver
Easily create & extract archives, and compress & decompress files of various formats
Stars: ✭ 3,373 (+8332.5%)
Mutual labels:  gzip, bzip2, brotli, snappy, lz4
Compress
Optimized Go Compression Packages
Stars: ✭ 2,478 (+6095%)
Mutual labels:  compression, gzip, decompression, snappy, zstd
Turbobench
Compression Benchmark
Stars: ✭ 211 (+427.5%)
Mutual labels:  compression, gzip, brotli, zstd
ratarmount
Random Access Read-Only Tar Mount
Stars: ✭ 217 (+442.5%)
Mutual labels:  compression, gzip, bzip2, zstd
tiny
compress data for better performance
Stars: ✭ 21 (-47.5%)
Mutual labels:  compression, brotli, snappy, lz4
box
Box - Open Standard Archive Format, a zip killer.
Stars: ✭ 38 (-5%)
Mutual labels:  compression, brotli, snappy, deflate
zstdmt
Multithreading Library for Brotli, Lizard, LZ4, LZ5, Snappy and Zstandard
Stars: ✭ 107 (+167.5%)
Mutual labels:  brotli, snappy, zstd, lz4
power-gzip
POWER9 gzip engine documentation and code samples
Stars: ✭ 16 (-60%)
Mutual labels:  compression, gzip, decompression, deflate
BrotliSharpLib
Full C# port of Brotli compression algorithm
Stars: ✭ 77 (+92.5%)
Mutual labels:  compression, decompression, brotli
Compression
Node.js compression middleware
Stars: ✭ 2,506 (+6165%)
Mutual labels:  compression, gzip, deflate
restler
Restler is a beautiful and powerful Android app for quickly testing REST API anywhere and anytime.
Stars: ✭ 120 (+200%)
Mutual labels:  gzip, brotli, deflate
restio
HTTP Client for Dart inspired by OkHttp
Stars: ✭ 46 (+15%)
Mutual labels:  gzip, brotli, deflate
lambdafs
Efficient (de)compression package for AWS Lambda
Stars: ✭ 24 (-40%)
Mutual labels:  gzip, decompression, brotli
http compression
🗜️ Deno HTTP compression middleware
Stars: ✭ 34 (-15%)
Mutual labels:  compression, gzip, deflate
rbzip2
bzip2 for Ruby
Stars: ✭ 39 (-2.5%)
Mutual labels:  compression, bzip2, decompression
Fastify Compress
Fastify compression utils
Stars: ✭ 95 (+137.5%)
Mutual labels:  compression, gzip, brotli
Rust Brotli
Brotli compressor and decompressor written in rust that optionally avoids the stdlib
Stars: ✭ 504 (+1160%)
Mutual labels:  compression, decompression, brotli
zstd-rs
zstd-decoder in pure rust
Stars: ✭ 148 (+270%)
Mutual labels:  compression, decompression, zstd
deflate-rs
An implementation of a DEFLATE encoder in rust
Stars: ✭ 47 (+17.5%)
Mutual labels:  compression, gzip, deflate

pyrus-cramjam

Code Style CI PyPI Anaconda-Server Badge Downloads

API Documentation

Install

pip install --upgrade cramjam  # Requires no Python or system dependencies!

Extremely thin Python bindings to de/compression algorithms in Rust. Allows for using algorithms such as Snappy, without any system dependencies.

This is handy when being used in environments like AWS Lambda, where installing packages like python-snappy becomes difficult because of system level dependencies.


Benchmarks

Some basic benchmarks are available in the benchmarks directory


Available algorithms:

  • Snappy
  • Brotli
  • Bzip2
  • Lz4
  • Gzip
  • Deflate
  • ZSTD

All available for use as:

>>> import cramjam
>>> import numpy as np
>>> compressed = cramjam.snappy.compress(b"bytes here")
>>> decompressed = cramjam.snappy.decompress(compressed)
>>> decompressed
cramjam.Buffer(len=10)  # an object which implements the buffer protocol
>>> bytes(decompressed)
b"bytes here"
>>> np.frombuffer(decompressed, dtype=np.uint8)
array([ 98, 121, 116, 101, 115,  32, 104, 101, 114, 101], dtype=uint8)

Where the API is cramjam.<compression-variant>.compress/decompress and accepts bytes/bytearray/numpy.array/cramjam.File/cramjam.Buffer objects.

de/compress_into Additionally, all variants support decompress_into and compress_into. Ex.

>>> import numpy as np
>>> from cramjam import snappy, Buffer
>>>
>>> data = np.frombuffer(b'some bytes here', dtype=np.uint8)
>>> data
array([115, 111, 109, 101,  32,  98, 121, 116, 101, 115,  32, 104, 101,
       114, 101], dtype=uint8)
>>>
>>> compressed = Buffer()
>>> snappy.compress_into(data, compressed)
33  # 33 bytes written to compressed buffer
>>>
>>> compressed.tell()  # Where is the buffer position?
33  # goodie!
>>>
>>> compressed.seek(0)  # Go back to the start of the buffer so we can prepare to decompress
>>> decompressed = b'0' * len(data)  # let's write to `bytes` as output
>>> decompressed
b'000000000000000'
>>>
>>> snappy.decompress_into(compressed, decompressed)
15  # 15 bytes written to decompressed
>>> decompressed
b'some bytes here'

Special note!
If you know the length of the de/compress output, you can provide output_len=<<some int>> to any de/compress to get ~1.5-3x performance increase as this allows single buffer allocation; doesn't really apply if you're using cramjam.Buffer or cramjam.File objects.

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].