title: How to convert pointer to c array to python array
body: <p>I have a C++ callback function that calls into Python using ctypes.  This function's parameters are a pointer to an array of double and the number of elements.</p>
  
  <p>There are a lot of elements, approximately 2,000,000.  I need to send this into scipy functions.</p>
  
  <p>The C++ prototype is :</p>
  
  <pre><code>bool (*ptsetDataSource)(double*, long long);
  </code></pre>
  
  <p>which is the following python code:</p>
  
  <pre><code>CPF_setDataSource = CFUNCTYPE(c_bool, POINTER(c_double),c_longlong)
  CPF_setSelection= CFUNCTYPE(c_bool,c_char_p, c_longlong,c_longlong)
  CPF_ResetSequence = CFUNCTYPE(c_bool)
  
  def setDataSource(Data, DataLength):
      Datalist=[0.0]*100
      for i in range(0,100):
          Datalist[i]=Data[i]
  
      print Datalist
      return True
  </code></pre>
  
  <p>The problem is that print datalist returns:</p>
  
  <pre><code>[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
  </code></pre>
  
  <p>which is not correct(data is filled with a lot of other numbers when checked on the c++ side.</p>
  
  <p>Also, if I use this code to convert the data to a python list, it locks up the computer at the allocate step.  </p>
  
  <p>Is there anyway to load the data from the C++ array and then convert it to an array fit for scipy?</p>