擅长:python、mysql、java
显然,将C++向量“(c)”数组“投”是微不足道的,请参阅这个问题的答案:<a href="https://stackoverflow.com/questions/2923272/how-to-convert-vector-to-array-c">How to convert vector to array in C++</a></p>
<p>接下来,您可以创建一个numpy数组,它将在不复制的情况下使用该C数组,请参见<a href="https://groups.google.com/forum/?fromgroups=#!topic/cython-users/Ubh2nG0_R9g" rel="nofollow noreferrer">discussion here</a>,或者google for <code>PyArray_SimpleNewFromData</code>。</p>
<p>我不希望SWIG自动为您完成所有这些工作,相反,您可能应该自己为函数<code>getValues</code>编写一个包装器,类似于<code>getValuesAsNumPyArray</code>。</p>