_pypy_raw_address returnes the same adress for the "view"

Issue #37 resolved
Konstantin Lopukhin created an issue

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)

  1. mattip

    The "official" way AFAIK is x.__array_interface__['data'][0], and indeed

    x[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

  2. Konstantin Lopukhin 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.

  3. Log in to comment