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 = '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.init()¶
Initialize the Blosc library environment.
- numcodecs.blosc.destroy()¶
Destroy the Blosc library environment.
- numcodecs.blosc.compname_to_compcode(cname)¶
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(int nthreads)¶
Set the number of threads that Blosc uses internally for compression and decompression.
- numcodecs.blosc.cbuffer_sizes(source)¶
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(source)¶
Return the name of the compression library used to compress source.
- numcodecs.blosc.cbuffer_metainfo(source)¶
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(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.
- numcodecs.blosc.decompress_partial(source, start, nitems, dest=None)¶
Experimental Decompress data of only a part of a buffer.
- Parameters:
- sourcebytes-like
Compressed data, including blosc header. Can be any object supporting the buffer protocol.
- start: int,
Offset in item where we want to start decoding
- nitems: int
Number of items we want to decode
- destarray-like, optional
Object to decompress into.
- Returns:
- destbytes
Object containing decompressed data.