[Numpy-discussion] How to resize numpy.memmap?
Pearu Peterson
pearu.peterson at gmail.com
Sun Jun 6 15:19:35 EDT 2010
Hi,
I am creating a rather large file (typically 100MBi-1GBi) with numpy.memmap
but in some cases the initial estimate to the file size is just few
bytes too small.
So, I was trying to resize the memmap with a failure as demonstrated
with the following
example:
>>> fp = numpy.memmap('test.dat', shape=(10,), mode='w+')
>>> fp.resize(11, refcheck=False)
...
ValueError: cannot resize this array: it does not own its data
My question is, is there a way to "fix" this or may be there exist some other
technique to resize memmap. I have tried resizing memmap's _mmap attribute
directly:
>>> fp._mmap.resize(11)
>>> fp._mmap.size()
11
but the size of memmap instance remains unchanged:
>>> fp.size
10
Thanks,
Pearu
More information about the NumPy-Discussion
mailing list