Skip to main content
`Ctrl`+`K`

# Blosc

class numcodecs.blosc.Blosc(cname='lz4', clevel=5, shuffle=1, blocksize=0, typesize=None)

  Codec providing compression using the Blosc meta-compressor.

  Parameters:
    cname string, optional

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

    clevel integer, optional

      An integer between 0 and 9 specifying the compression level.

    shuffle integer, 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.

    blocksize int

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

    typesize int, optional

      The size in bytes of uncompressed array elements.

  See also

  `numcodecs.zstd.Zstd`, `numcodecs.lz4.LZ4`
  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.

## 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, typesize=None)

  Compress data.

  Parameters:
    source bytes-like

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

    cname bytes

      Name of compression library to use.

    clevel int

      Compression level.

    shuffle int

      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.

    blocksize int

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

  Returns:
    dest bytes

      Compressed data.

numcodecs.blosc.decompress(source, dest=None)

  Decompress data.

  Parameters:
    source bytes-like

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

    dest array-like, optional

      Object to decompress into.

  Returns:
    dest bytes

      Object containing decompressed data.