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 ?)

cheers,

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

Reply via email to