how to get the memory address of a numpy array for C

后端 未结 2 750
慢半拍i
慢半拍i 2020-12-15 04:53

I constructed an numpy array::

a=np.ndarray([2,3]) 

then i want to see where its data are::

a.data 
>>>Out[213]: &         


        
相关标签:
2条回答
  • 2020-12-15 05:18

    a.data might be a property whose getter function creates a new buffer object (meta data) on each call.

    To get the address see how numpy.ctypeslib.as_ctypes() is implemented.

    0 讨论(0)
  • 2020-12-15 05:37

    Also, have a look at ndarray.__array_interface__, which is a dict that contains all of the information you're after.

    In your case,

    pointer, read_only_flag = a.__array_interface__['data']
    
    0 讨论(0)
提交回复
热议问题