Blosc#
- class numcodecs.blosc.Blosc(cname='lz4', clevel=5, shuffle=1, blocksize=0)#
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 AUTOSHUFFLE, bit-shuffle will be used for buffers with itemsize 1, and byte-shuffle will be used otherwise. The default is SHUFFLE.
- blocksizeint
The requested size of the compressed blocks. If 0 (default), an automatic blocksize will be used.
See also
- codec_id: str | None = 'blosc'#
Codec identifier.
- NOSHUFFLE = 0#
- SHUFFLE = 1#
- BITSHUFFLE = 2#
- AUTOSHUFFLE = -1#
- encode(self, buf)#
- decode(self, buf, out=None)#
- get_config()#
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.
- decode_partial(self, buf, int start, int nitems, out=None)#
Experimental
Helper functions#
- 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(int nthreads)#
Set the number of threads that Blosc uses internally for compression and decompression.
- numcodecs.blosc.cbuffer_complib(source)#
Return the name of the compression library used to compress source.
- numcodecs.blosc.compress(source, char *cname, int clevel, int shuffle=SHUFFLE, int blocksize=AUTOBLOCKS)#
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 AUTOSHUFFLE, bit-shuffle will be used for buffers with itemsize 1, and byte-shuffle will be used otherwise. The default is SHUFFLE.
- blocksizeint
The requested size of the compressed blocks. If 0, an automatic blocksize will be used.
- Returns:
- destbytes
Compressed data.
- numcodecs.blosc.decompress(source, dest=None)#
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.