当我读到Sven的回复时,我也有同样的问题,感到失望.似乎numpy将错过一些关键的功能,如果你不能有一个巨大的数组文件,并在一小块工作一次.您的案例似乎接近使用.npy格式的原始理性的一个用例(参见:
http://svn.scipy.org/svn/numpy/trunk/doc/neps/npy-format.txt).
然后我碰到了numpy.lib.format,这似乎是有用的好东西.我不知道为什么这个功能是不可用的numpy根包.与HDF5相比,它的主要优点在于它带有麻烦.
>>> print numpy.lib.format.open_memmap.__doc__
"""
Open a .npy file as a memory-mapped array.
This may be used to read an existing file or create a new one.
Parameters
----------
filename : str
The name of the file on disk. This may not be a filelike object.
mode : str, optional
The mode to open the file with. In addition to the standard file modes,
'c' is also accepted to mean "copy on write". See `numpy.memmap` for
the available mode strings.
dtype : dtype, optional
The data type of the array if we are creating a new file in "write"
mode.
shape : tuple of int, optional
The shape of the array if we are creating a new file in "write"
mode.
fortran_order : bool, optional
Whether the array should be Fortran-contiguous (True) or
C-contiguous (False) if we are creating a new file in "write" mode.
version : tuple of int (major, minor)
If the mode is a "write" mode, then this is the version of the file
format used to create the file.
Returns
-------
marray : numpy.memmap
The memory-mapped array.
Raises
------
ValueError
If the data or the mode is invalid.
IOError
If the file is not found or cannot be opened correctly.
See Also
--------
numpy.memmap
"""