SChunk.decompress_chunk#

SChunk.decompress_chunk(nchunk: int, dst: object = None) str | bytes#

Decompress the chunk given by its index nchunk.

Parameters:
  • nchunk (int) – The index of the chunk that will be decompressed.

  • dst (NumPy object or bytearray) – The destination NumPy object or bytearray to fill, the length of which must be greater than 0. The user must ensure that it has enough capacity to host the decompressed chunk. Default is None, meaning that a new bytes object is created, filled and returned.

Returns:

out – The decompressed chunk as a Python str or bytes object if dst is None. Otherwise, it returns None because the result will already be in dst.

Return type:

str or bytes

Raises:

RunTimeError – If a problem is detected.

Examples

>>> import blosc2
>>> cparams = blosc2.CParams(typesize=1)
>>> schunk = blosc2.SChunk(cparams=cparams)
>>> buffer = b"wermqeoir23"
>>> schunk.append_data(buffer)
1
>>> schunk.decompress_chunk(0)
b'wermqeoir23'
>>> # Construct a mutable bytearray object
>>> bytes_obj = bytearray(len(buffer))
>>> schunk.decompress_chunk(0, dst=bytes_obj)
>>> bytes_obj == buffer
True