title: How to pass pointer to an array in Python for a wrapped C++ function
body: <p>I am new to C++/Python mixed language programming and do not have much idea about Python/C API. I just started using Boost.Python to wrap a C++ library for Python. I am stuck at wrapping a function that takes pointer to an array as an argument. Following (2nd ctor) is its prototype in C++.</p>
  
  <pre><code>class AAF{
    AAF(AAF_TYPE t);
    AAF(double v0, const double * t1, const unsigned * t2, unsigned T);
    ~AAF();
  }
  </code></pre>
  
  <p>Am I doing right by wrapping it like this in boost::python?</p>
  
  <pre><code>class_&lt;AAF&gt;("AAF", init&lt;AAF_TYPE&gt;())
    .def(init&lt;double, const double*, const unsigned*, unsigned&gt;());
  </code></pre>
  
  <p>Note that it compiled and linked successfully, but I couldn't figure out how to call it in Python. My naive tries like the following failed.</p>
  
  <pre><code>&gt;&gt;&gt; z = AAF(10, [4, 5.5, 10], [1, 1, 2], 3);
  
  Traceback (most recent call last):
    File "./test_interval.py", line 40, in &lt;module&gt;
      z = AAF(10, [4, 5.5, 10], [1, 1, 2], 3);
  Boost.Python.ArgumentError: Python argument types in
      AAF.__init__(AAF, int, list, list, int)
  did not match C++ signature:
      __init__(_object*, AAF_TYPE)
      __init__(_object*, double, double const*, unsigned int const*, unsigned int)
  
  &gt;&gt;&gt; t1 = array.array('d', [4, 5.5, 10])
  &gt;&gt;&gt; t2 = array.array('I', [1, 1, 2])
  &gt;&gt;&gt; z = AAF(10, t1, t2, 3);
  
  Traceback (most recent call last):
    File "./test_interval.py", line 40, in &lt;module&gt;
      z = AAF(10, t1, t2, 3);
  Boost.Python.ArgumentError: Python argument types in
      AAF.__init__(AAF, int, array.array, array.array, int)
  did not match C++ signature:
      __init__(_object*, AAF_TYPE)
      __init__(_object*, double, double const*, unsigned int const*, unsigned int)
  </code></pre>
  
  <p>My second question is that do I also need to wrap the destructor? Please specify if this might be necessary in some cases but not always.</p>