<br><br><div class="gmail_quote">On Sat, Sep 22, 2012 at 9:46 AM, Olivier Grisel <span dir="ltr"><<a href="mailto:olivier.grisel@ensta.org" target="_blank">olivier.grisel@ensta.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
There is also a third use case that is problematic on numpy master:<br>
<div class="im"><br>
orig = np.memmap('tmp.mmap', dtype=np.float64, shape=100, mode='w+')<br>
orig[:] = np.arange(orig.shape[0]) * -1.0  # negative markers to<br>
detect under / overflows<br>
<br>
a = np.memmap('tmp.mmap', dtype=np.float64, shape=50, mode='r+', offset=16)<br>
a[:] = np.arange(50)<br>
</div>b = np.asarray(a[10:])<br>
<br>
Now b does not even have a 'filename' attribute anymore. `b.base` is a<br>
python mmap instance but the later is created with a file descriptor.<br>
<br>
It would still be possible to use:<br>
<br>
from _multiprocessing import address_of_buffer<br>
<br>
to find the memory address of the mmap buffer and use than to open new<br>
buffer views on the same memory segment from subprocesses using<br>
`numpy.frombuffer((ctypes.c_byte * n_byte).fromaddress(addr))` but in<br>
case of failure (e.g. the file has been deleted on the HDD) one gets a<br>
segmentation fault instead of a much more userfriendly catchable file<br>
not found exception.<br></blockquote><div><br>Would some sort of 'dup' method be useful?<br><br>Chuck <br></div><br></div>