title: Portable/fast way to obtain a pointer to Numpy/Numpypy data
body: <p>I recently tried <code>PyPy</code> and was intrigued by the approach. I have lots of C extensions for Python, which all use <code>PyArray_DATA()</code> to obtain a pointer to the data sections of <code>numpy</code> arrays. Unfortunately, PyPy doesn't appear to export an equivalent for their <code>numpypy</code> arrays in their <code>cpyext</code> module, so I tried following the recommendation on their website to use <code>ctypes</code>. This pushes the task of obtaining the pointer to the Python level.</p>
  
  <p>There appear to be two ways:</p>
  
  <pre><code>import ctypes as C
  p_t = C.POINTER(C.c_double)
  
  def get_ptr_ctypes(x):
      return x.ctypes.data_as(p_t)
  
  def get_ptr_array(x):
      return C.cast(x.__array_interface__['data'][0], p_t)
  </code></pre>
  
  <p>Only the second one works on PyPy, so for compatibility the choice is clear. For CPython, both are slow as hell and a complete bottleneck for my application! Is there a fast and portable way of obtaining this pointer? Or is there an equivalent of <code>PyArray_DATA()</code> for PyPy (possibly undocumented)?</p>