spdl.io.load_npz

load_npz(data: bytes) NpzFile[source]

[Experimental] Load a numpy archive file (npz).

It is almost a drop-in replacement for numpy.load() function, but it only supports the basic use cases.

This function uses the C++ implementation of the zip archive reader, which releases the GIL. So it is more efficient than the official NumPy implementation for supported cases.

Parameters:

data – The data to load.

Example

>>> x = np.arange(10)
>>> y = np.sin(x)
>>>
>>> with tempfile.TemporaryFile() as f:
...     np.savez(f, x=x, y=y)
...     f.seek(0)
...     data = spdl.io.load_npz(f.read())
...
>>> assert np.array_equal(data["x"], x)
>>> assert np.array_equal(data["y"], y)