blosc2.pack_array2#

blosc2.pack_array2(arr: ndarray, chunksize: int = None, **kwargs: dict) bytes | int#

Pack (compress) a NumPy array. This is faster, and it does not have a 2 GB limitation.

Parameters:
  • arr (np.ndarray) – The NumPy array to be packed.

  • chunksize (int) – The size (in bytes) for the chunks during compression. If not provided, it is computed automatically.

  • kwargs (dict, optional) – These are the same as the kwargs in SChunk.__init__.

Returns:

out – The serialized version (cframe) of the array. If urlpath is provided, the number of bytes in file is returned instead.

Return type:

bytes | int

Examples

>>> import numpy as np
>>> a = np.arange(1e6)
>>> cframe = blosc2.pack_array2(a)
>>> len(cframe) < a.size * a.itemsize
True