Skip to main content
`Ctrl`+`K`

# Zstd

class numcodecs.zstd.Zstd(level=0, checksum=False)

  Codec providing compression using Zstandard.

  Parameters:
    level int

      Compression level (-131072 to 22).

    checksum bool

      Flag to enable checksums. The default is False.

  See also

  `numcodecs.lz4.LZ4`, `numcodecs.blosc.Blosc`
  codec_id: str | None = 'zstd'

    Codec identifier.

  encode(self, buf)
  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.zstd.compress(source, int level=DEFAULT_CLEVEL, bool checksum=False)

  Compress data.

  Parameters:
    source bytes-like

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

    level int

      Compression level (-131072 to 22).

    checksum bool

      Flag to enable checksums. The default is False.

  Returns:
    dest bytes

      Compressed data.

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

  Decompress data.

  Parameters:
    source bytes-like

      Compressed data. Can be any object supporting the buffer protocol.

    dest array-like, optional

      Object to decompress into. If the content size is unknown, the length of dest must match the decompressed size. If the content size is unknown and dest is not provided, streaming decompression will be used.

  Returns:
    dest bytes

      Object containing decompressed data.