cramjam.xz

xz and lzma de/compression interface

def compress( data, preset=None, format=None, check=None, filters=None, options=None, output_len=None):

LZMA compression.

Python Example
>>> _ = cramjam.xz.compress(b'some bytes here')
>>> # Defaults to XZ format, you can use the deprecated LZMA format like this:
>>> _ = cramjam.xz.compress(b'some bytes here', format=cramjam.xz.Format.ALONE)
def compress_into( input, output, preset=None, format=None, check=None, filters=None, options=None):

Compress directly into an output buffer

def decompress(data, output_len=None):

LZMA decompression.

Python Example
>>> # bytes or bytearray; bytearray is faster
>>> cramjam.xz.decompress(compressed_bytes, output_len=Optional[None])
def decompress_into(input, output):

Decompress directly into an output buffer

class Compressor:

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

class Filter:

Available Filter IDs

Arm = Filter.Arm
ArmThumb = Filter.ArmThumb
Ia64 = Filter.Ia64
Lzma1 = Filter.Lzma1
Lzma2 = Filter.Lzma2
PowerPC = Filter.PowerPC
Sparc = Filter.Sparc
X86 = Filter.X86
class MatchFinder:

MatchFinder, used with Options.mf attribute

HashChain3 = MatchFinder.HashChain3
HashChain4 = MatchFinder.HashChain4
BinaryTree2 = MatchFinder.BinaryTree2
BinaryTree3 = MatchFinder.BinaryTree3
BinaryTree4 = MatchFinder.BinaryTree4
class Mode:

MatchFinder, used with Options.mode attribute

Fast = Mode.Fast
Normal = Mode.Normal
class FilterChain:

FilterChain, similar to the default Python XZ filter chain which is a list of dicts.

def append_filter(self, /, filter_chain_item):
class FilterChainItem:

FilterChainItem. In Python's lzma module, this represents a single dict in the filter chain list. To be added to the FilterChain

class Options:
def set_preset(self, /, preset):
def set_dict_size(self, /, dict_size):
def set_lc(self, /, lc):
def set_lp(self, /, lp):
def set_pb(self, /, pb):
def set_mode(self, /, mode):
def set_nice_len(self, /, nice_len):
def set_mf(self, /, mf):
def set_depth(self, /, depth):
class Format:

Possible formats

AUTO = Format.AUTO
XZ = Format.XZ
ALONE = Format.ALONE
RAW = Format.RAW
class Check:

Possible Check configurations

Crc64 = Check.Crc64
Crc32 = Check.Crc32
Sha256 = Check.Sha256
None = Check.None