[Numpy-discussion] numpy array sharing between processes? (and ctypes)

Travis Oliphant oliphant.travis at ieee.org
Mon May 14 15:01:13 EDT 2007


Ray S wrote:
> print N.diag(x)
>
> Works for me...
>
> I can then do:
>  >>> import  numpy.core.multiarray as MA
>  >>> xBuf = MA.getbuffer(x)
>  >>> z = MA.frombuffer(xBuf).reshape((3,3))
>   

I see this kind of importing used more often than it should be. 

It is dangerous to import directly from numpy.core and numpy.lib and 
even more dangerous to import directly from files in those 
sub-packages.  The organization of the files may change suddenly in the 
future.  The only guarantee is that the numpy name-space will not change 
suddenly.

These namespaces are all incorporated in numpy. 

Thus,

numpy.getbuffer
numpy.frombuffer

are the recommended ways to use this functionality.

-Travis




More information about the NumPy-Discussion mailing list