Tuesday, 15 July 2014

gzip - How does numpy handle mmap's over npz files? -


I have a case where I would like to open a compressed MMP file using Mmapi mode, but not any search Find documentation about how it will work under the cover. For example, will it uncompress the collection in memory and then it's MMAP? Will it remove compression on the fly?

The documentation is absent for that configuration.

Based on the short answer, code view, archive and compression, np.savez < / Code> or gzip , regardless of accessing files in mmap_mode . It is not a matter of how it is done, but it can be done at all.

np.load function

<> elif isinstance (file, gzip.GzipFile): Fid = seek_gzip_factory (file) ... If magic.startswith (_ZIP_PREFIX): # ZIP file NpzFile tmp = own_fid own_fid = wrong (.npz value) # transfer ownership back to the file NpzFile (FID, own_fid = tmp) ... if mmap_mode: return format.open_memmap (file , Mode = mmap_mode)

Look at np.lib.npyio.NpzFile . A npz file .npy is a Zip archive files a dictionary (like) object to load, and when you access them, individual variable (Array ) (Like obj [key]). There is no provision in its code to open those personal files in mmap_mode`.

It is very clear that the file created with np.savez can not be used as an mmap. Zip archive and compression is not a single form of gzip compression saved in the np.load first of what is addressed with np.save <.

But / code> and then gzipped ? Note that format.open_memmap is not called the file fid (which may be a gzip file). Details on

and open_memmap on np.lib.npyio.format . Its first test is that the file should be a string, not an existing file feed. This work expires to work on np.memmap I do not see any provision in that function for gzip .


No comments:

Post a Comment