Compressor

class asdf.extension.Compressor(*args, **kwargs)[source]

Bases: _Compress, _Decompress, Protocol

Protocol for compression extensions.

Attributes Summary

label

Get the 4-byte label identifying this compression

Methods Summary

compress(data, **kwargs)

Compress data, yielding the results.

decompress(data, out, **kwargs)

Decompress data, writing the result into out.

Attributes Documentation

label

Get the 4-byte label identifying this compression

Returns:
labelbytes

The compression label

Methods Documentation

compress(data: memoryview, **kwargs) → Iterator[bytes]

Compress data, yielding the results. The yield may be block-by-block, or all at once.

Parameters:
datamemoryview

The data to compress. Must be contiguous and 1D, with the underlying itemsize preserved.

**kwargs

Keyword arguments to be passed to the underlying compression function

Yields:
compressedbytes-like

A block of compressed data

decompress(data: Iterable[bytes], out: memoryview, **kwargs) → int

Decompress data, writing the result into out.

Parameters:
dataIterable of bytes-like

An Iterable of bytes-like objects containing chunks of compressed data.

outread-write bytes-like

A contiguous, 1D output array, of equal or greater length than the decompressed data.

**kwargs

Keyword arguments to be passed to the underlying decompression function

Returns:
nbytesint

The number of bytes written to out