title: Faster way to convert ctypes array to python list?
body: <p>I was wondering if someone could advise me whether there is a better/faster approach to read data from my C program that outputs two lists of size <em>n</em>. I am using <code>ctypes</code> to call the C program.</p>
  
  <p>The loop I show below works by iterating over a number of scans. For each scan two lists are produced (<code>msX, msY</code>). The <code>c_float</code> data is extracted by using list comprehension loop. Is there a better/faster way to convert the <code>c_float_Array</code>  obtained from mzP and mzI to <code>msX</code> and <code>msY</code>?</p>
  
  <pre><code>for scan in xrange(nScans):
      mzP = (c_float * nPoints)() # pointer to list 1, c_float_Array
      mzI = (c_float * nPoints)() # pointer to list 2,  c_float_Array
      mlLib.readData(filePointer, 1, scan, byref(mzP), byref(mzI))
      # The slow part...
      msX = [mzP[i] for i in xrange(nPoints)] # list with mzP data
      msY = [mzI[i] for i in xrange(nPoints)] # list with mzI data
  </code></pre>
  
  <p>Let me know if my question is not clear.
  Thanks for your help in advance.</p>