We can save many arrays, one after another, without having all of them in RAM at the same time with:
with open('test.npy', 'wb') as f:
A = compute_my_np_array(1)
np.save(f, A)
# we could even do: del A (but not needed here, because it is freed anyway in the next line)
A = compute_my_np_array(2)
np.save(f, A)
but it is uncompressed. For compressed save, we have to have all arrays available at the same time, see numpy.savez_compressed:
A = compute_my_np_array(1)
B = compute_my_np_array(2)
np.savez_compressed('test.npz', A=A, B=B)
TL;DR: how to save compressed numpy arrays without having all of them in RAM at the same time?