_pypy_raw_address returnes the same adress for the "view"
Issue #37
resolved
Is data._pypy_raw_address() the "official" way to get a pointer in order to pass to C code? If so, it behaves a bit differently from CPython - it changes in CPython and stays the same in PyPy when taking a slice/view (not sure about proper name).
CPython:
>>> x = np.zeros((2, 3))
>>> x.ctypes.data
140390306962032
>>> x[1,:].ctypes.data
140390306962056
PyPy:
>>>> x = np.zeros((2, 3))
>>>> x.data._pypy_raw_address()
4343782832
>>>> x[1,:].data._pypy_raw_address()
4343782832
Comments (4)
-
-
reporter Ah, nice, than it's perfect. Maybe x.data._pypy_raw_adress just always returns the adress of the underlying data objects that still contains the whole array.
-
- changed status to resolved
fixed in pypy/pypy /commit/9eb2238aaf11
-
reporter Thank you!
- Log in to comment
The "official" way AFAIK is
x.__array_interface__['data'][0]
, and indeedx[1,:].__array_interface__['data'][0] - x.__array_interface__['data'][0] == 24 == x.strides[0]
but I am looking into what is
x[1,:].data.__pypy_raw_address()
and why it is wrong