blosc2.save_array#

blosc2.save_array(arr: ndarray, urlpath: str, chunksize: int | None = None, **kwargs: dict) int#

Save a serialized NumPy array to a specified file path.

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

  • urlpath (str) – The path for the file where the array will be saved.

  • 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 number of bytes of the saved array.

Return type:

int

Examples

>>> import numpy as np
>>> a = np.arange(1e6)
>>> serial_size = blosc2.save_array(a, "test.bl2", mode="w")
>>> serial_size < a.size * a.itemsize
True