Blosc

class numcodecs.blosc.Blosc

Codec providing compression using the Blosc meta-compressor.

Parameters
cnamestring, optional

A string naming one of the compression algorithms available within blosc, e.g., ‘zstd’, ‘blosclz’, ‘lz4’, ‘lz4hc’, ‘zlib’ or ‘snappy’.

clevelinteger, optional

An integer between 0 and 9 specifying the compression level.

shuffleinteger, optional

Either NOSHUFFLE (0), SHUFFLE (1), BITSHUFFLE (2) or AUTOSHUFFLE (-1). If -1 (default), bit-shuffle will be used for buffers with itemsize 1, and byte-shuffle will be used otherwise.

blocksizeint

The requested size of the compressed blocks. If 0 (default), an automatic blocksize will be used.

codec_id = 'blosc'
NOSHUFFLE = 0
SHUFFLE = 1
BITSHUFFLE = 2
AUTOSHUFFLE = -1
encode(self, buf)
decode(self, buf, out=None)
get_config(self)

Return a dictionary holding configuration parameters for this codec. Must include an ‘id’ field with the codec identifier. All values must be compatible with JSON encoding.

classmethod from_config(config)

Instantiate codec from a configuration object.

Helper functions

numcodecs.blosc.init()

Initialize the Blosc library environment.

numcodecs.blosc.destroy()

Destroy the Blosc library environment.

numcodecs.blosc.compname_to_compcode()

Return the compressor code associated with the compressor name. If the compressor name is not recognized, or there is not support for it in this build, -1 is returned instead.

numcodecs.blosc.list_compressors()

Get a list of compressors supported in the current build.

numcodecs.blosc.get_nthreads()

Get the number of threads that Blosc uses internally for compression and decompression.

numcodecs.blosc.set_nthreads()

Set the number of threads that Blosc uses internally for compression and decompression.

numcodecs.blosc.cbuffer_sizes()

Return information about a compressed buffer, namely the number of uncompressed bytes (nbytes) and compressed (cbytes). It also returns the blocksize (which is used internally for doing the compression by blocks).

Returns
nbytesint
cbytesint
blocksizeint
numcodecs.blosc.cbuffer_complib()

Return the name of the compression library used to compress source.

numcodecs.blosc.cbuffer_metainfo()

Return some meta-information about the compressed buffer in source, including the typesize, whether the shuffle or bit-shuffle filters were used, and the whether the buffer was memcpyed.

Returns
typesize
shuffle
memcpyed
numcodecs.blosc.compress()

Compress data.

Parameters
sourcebytes-like

Data to be compressed. Can be any object supporting the buffer protocol.

cnamebytes

Name of compression library to use.

clevelint

Compression level.

shuffleint

Either NOSHUFFLE (0), SHUFFLE (1), BITSHUFFLE (2) or AUTOSHUFFLE (-1). If -1 (default), bit-shuffle will be used for buffers with itemsize 1, and byte-shuffle will be used otherwise.

blocksizeint

The requested size of the compressed blocks. If 0, an automatic blocksize will be used.

Returns
destbytes

Compressed data.

numcodecs.blosc.decompress()

Decompress data.

Parameters
sourcebytes-like

Compressed data, including blosc header. Can be any object supporting the buffer protocol.

destarray-like, optional

Object to decompress into.

Returns
destbytes

Object containing decompressed data.