On 10/9/07, David Cournapeau <[EMAIL PROTECTED]> wrote:
> Sebastian Haase wrote:
> > Hi!
> > I was in fact experimenting with this. The solution seemed to lie in
> > "simple" memmap as it is implemented in Windows:
> >
> > import numpy as N
> > def arrSharedMemory(shape, dtype, tag="PriithonSharedMemory"):
> >     """
> >     Windows only !
> >     share memory between different processes if same `tag` is used.
> >     """
> >     itemsize = N.dtype(dtype).itemsize
> >     count = N.product(shape)
> >     size =  count * itemsize
> >
> >     import mmap
> >     sharedmem = mmap.mmap(0, size, tag)
> >     a=N.frombuffer(sharedmem, dtype, count)
> >     a.shape = shape
> >     return a
> >
> > For explaintion look up the microsoft site for the mmap documentation.
> > And/or the Python-doc for mmap.
> > (( I have to mention, that I could crash a process while testing this ... ))
> >
> > If anyone here would know an equivalent way of doing this on
> > Linux/OS-X  we were back to a cross-platfrom function.
> >
> AFAIK, the tag thing is pretty much windows specific, so why not just
> ignoring it on non windows platforms ? (or interpreting the tag argument
> as the flag argument for mmap, which would be consistent with python
> mmap API ?)
>
As I recollect, the tag thing was the key for  turning the mmap into a
"not really memmaped file", that is, a memmap without a corresponding
file on the disk.
In other words, isn't a mmap ( without(!) tag ) always bound to a
"real" file in the file system ?

-Sebastian
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to