blosc2.unpack#

blosc2.unpack(packed_object: str | bytes, **kwargs: dict) object#

Unpack (decompress) an object.

Parameters:
  • packed_object (str or bytes) – The packed object to be decompressed.

  • kwargs (dict, optional) – Parameters that can be passed to the pickle.loads API

Returns:

out – The decompressed data in form of the original object.

Return type:

object

Raises:

TypeError – If packed_object is not of type bytes or string.

Examples

>>> import numpy as np
>>> a = np.arange(1e6)
>>> parray = blosc2.pack(a)
>>> len(parray) < a.size * a.itemsize
True
>>> a2 = blosc2.unpack(parray)
>>> np.array_equal(a, a2)
True
>>> a = np.array(['å', 'ç', 'ø'])
>>> parray = blosc2.pack(a)
>>> a2 = blosc2.unpack(parray)
>>> np.array_equal(a, a2)
True