Shared memory and numpy arrays #1329
-
Greetings once again!
I think I was expecting the underlying data to be the same bit of memory. I guess that's not so? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Ah - maybe it is?
|
Beta Was this translation helpful? Give feedback.
-
@PaulRudin In [3]: import vineyard
import
In [4]: import numpy as np
In [5]: client = vineyard.connect("/tmp/vineyard.sock")
In [6]: object_id = client.put(np.ones((10000, 1000)))
In [7]: r1 = client.get(object_id)
In [8]: r2 = client.get(object_id)
In [9]: r1 is r2
Out[9]: False
In [10]: r1.__array_interface__["data"]
Out[10]: (140492393889856, True)
In [11]: r2.__array_interface__["data"]
Out[11]: (140492393889856, True)
In [12]: r1.__array_interface__["data"] == r2.__array_interface__["data"]
Out[12]: True See https://stackoverflow.com/questions/11264838/how-to-get-the-memory-address-of-a-numpy-array-for-c for more discussion about the memory address of numpy ndarray. |
Beta Was this translation helpful? Give feedback.
@PaulRudin
numpy.ndarray.base.data
is not the memory address of the array payload. With vineyard, get the same object twice with the same client instance, the memory address should be the same.