title: return double * from swig as python list
body: <p>I have a C++ class, one of whose methods returns a <code>double *</code> array-like that is one of its member variables. I'm trying to make this accessible as a list in Python. I wrap it in a <code>doubleArray_frompointer</code>, and then try using deepcopy to get it out of there safely, but I still have problems when the <code>doubleArray</code> goes out of scope, its memory is cleaned up, and then the C++ class tries to clean up the same memory (although that's not shown in the <a href="https://gist.github.com/4349180" rel="nofollow">gist</a> I created).</p>
  
  <p>I suspect I should be doing this with typemaps. </p>
  
  <p>What I'm trying to wrap is:</p>
  
  <pre><code>double *foo() {
    double *toReturn = new double[2];
    toReturn[0] = 2;
    toReturn[1] = 4;
    return toReturn;
  }
  </code></pre>
  
  <p>and the interface is:</p>
  
  <pre><code>%module returnList
  %include "returnList.h"
  
  %include "cpointer.i"
  %pointer_functions(double, doubleP)
  
  %include "carrays.i"
  %array_class(double, doubleArray);
  
  %{
  #include "returnList.h"
  %}
  </code></pre>