blosc2.compress2#

blosc2.compress2(src: object, **kwargs: dict) str | bytes#

Compress the given src buffer with the specified compression parameters.

Parameters:
  • src (bytes-like object) – The buffer to compress. Must support the buffer interface.

  • kwargs (dict, optional) –

    Compression parameters. The default values are in blosc2.CParams. Supported keyword arguments:

    cparams: blosc2.CParams or dict

    All the compression parameters to use, provided as a blosc2.CParams instance or dictionary.

    others: Any

    If cparams is not provided, all the parameters of a blosc2.CParams can be passed as keyword arguments.

Returns:

out – The compressed data as a Python str or bytes object.

Return type:

str or bytes

Raises:

RuntimeError – If the data cannot be compressed into dst. If an internal error occurs, likely due to an invalid parameter.