New issue 1777: Unable to create proper numpy array from cffi buffer https://bitbucket.org/pypy/pypy/issue/1777/unable-to-create-proper-numpy-arr...
I am writing something that need to convert a c buffer from cffi to a numpy array with arbitrary shape and strides. Besides the fact that [`as_strided`](https://bitbucket.org/pypy/numpy/issue/9/numpylibstride_tricksas_strided-is-...) is not really working, another problem is that the c buffer is maintained by the underlaying c/c++ library (OpenCL in this case). Therefore it is necessary to let the numpy ndarray hold a reference of the object which manage the memory.
In CPython, this is done by [setting the base on the ndarray](https://github.com/pyopencl/pyopencl/blob/master/src/wrapper/wrap_cl.hpp#L27...). However, there doesn't seem to be a way to do the same in (num)pypy.
In pypy, although I can pass the buffer to `np.frombuffer` and call `reshape` to get an array roughly correct, the array is only holding a reference to the buffer returned by cffi but not the (c++) object (or the python delegate of it) which manages the memory. Furthermore, the base property of the result array cannot be used to access the underlying object (which is currently a PyOpenCL API that I would love not to break.)
(The problem can probably be solved along with the [`as_strided` support bug](https://bitbucket.org/pypy/numpy/issue/9/numpylibstride_tricksas_strided-is-...) by allowing creating arrays from object with a proper array interface)