[Numpy-discussion] Views of memmaps and offset

Charles R Harris charlesr.harris at gmail.com
Sat Sep 22 13:16:27 EDT 2012

On Sat, Sep 22, 2012 at 7:54 AM, Gael Varoquaux <
gael.varoquaux at normalesup.org> wrote:

> Hi list,
> I am struggling with offsets on the view of a memmaped array. Consider
> the following:
> import numpy as np
> a = np.memmap('tmp.mmap', dtype=np.float64, shape=50, mode='w+')
> a[:] = np.arange(50)
> b = a[10:]
> Here, I have a.offset == 0 and b.offset == 0. In practice, the data in b
> is offset compared to the start of the file, given that it is a view
> computed with an offset.
> My goal is, given b, to find a way to open a new view on the file, e.g.
> in a different process. For this I need the offset.
> Any idea of how I can retrieve it? In the previous numpy versions, I
> could go from b to a using the 'base' attribute of a. This is no longer
> possible.
> Also, should the above behavior be considered as a bug?

I think this is a bug, taking a view should probably update the offset.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120922/60482212/attachment.html>

More information about the NumPy-Discussion mailing list