cramjam.snappy

snappy de/compression interface

def decompress(data, output_len=None):

Snappy decompression.

Python Example
>>> # bytes or bytearray; bytearray is faster
>>> cramjam.snappy.decompress(compressed_bytes, output_len=Optional[None])
def compress(data, output_len=None):

Snappy compression.

Python Example
>>> _ = cramjam.snappy.compress(b'some bytes here')
>>> _ = cramjam.snappy.compress(bytearray(b'this avoids double allocation in rust side, and thus faster!'))  # <- use bytearray where possible
def decompress_raw(data, output_len=None):

Snappy decompression, raw This does not use the snappy 'framed' encoding of compressed bytes.

Python Example
>>> cramjam.snappy.decompress_raw(compressed_raw_bytes)
def compress_raw(data, output_len=None):

Snappy compression raw. This does not use the snappy 'framed' encoding of compressed bytes.

Python Example
>>> cramjam.snappy.compress_raw(b'some bytes here')
def compress_into(input, output):

Compress directly into an output buffer

def decompress_into(input, output):

Decompress directly into an output buffer

def compress_raw_into(input, output):

Compress raw format directly into an output buffer

def decompress_raw_into(input, output):

Decompress raw format directly into an output buffer

def compress_raw_max_len(data):

Get the expected max compressed length for snappy raw compression; this is the size of buffer that should be passed to compress_raw_into

def decompress_raw_len(data):

Get the decompressed length for the given data. This is the size of buffer that should be passed to decompress_raw_into

class Compressor:

Snappy Compressor object for streaming compression

def compress(self, /, input):

Compress input into the current compressor's stream.

def flush(self, /):

Flush and return current compressed stream

def finish(self, /):

Consume the current compressor state and return the compressed stream NB The compressor will not be usable after this method is called.

class Decompressor:

Decompressor object for streaming decompression NB This is mostly here for API complement to Compressor You'll almost always be statisfied with de/compress / de/compress_into functions.

def len(self, /):

Length of internal buffer containing decompressed data.

def decompress(self, /, input):

Decompress this input into the inner buffer.

def flush(self, /):

Flush and return current decompressed stream.

def finish(self, /):

Consume the current Decompressor state and return the decompressed stream NB The Decompressor will not be usable after this method is called.