擅长:python、mysql、java
<p>是的,会是新的。数组的数据布局与列表的数据布局非常不同。在</p>
<p>数组具有shape和stripes之类的属性,以及一个包含元素的1d数据缓冲区(只是一组连续的字节)。其他属性和代码将它们视为float、int、strings、1d、2d等</p>
<p>列表是指针的缓冲区,每个指针都指向内存中其他位置的对象。它可以指向一个数字、一个字符串或另一个列表。它不会指向数组的数据缓冲区或其中的元素。在</p>
<p>有使用编译代码的numpy数组和利用数组数据缓冲区的C数组的接口。<code>cython</code>是上的公共项。关于numpy的capi还有一个完整的文档部分。{cd2>什么都知道。如果它需要一个列表接口,它可能不是最好的。在</p>
<p>当我用^{<cd4>做了<code>timeit</code>测试时,它似乎没有那么贵。在</p>
<p>======================</p>
<p>但是看看<code>pybind11</code>github,我发现有很多引用<code>numpy</code>,而这个</p>
<p><a href="http://pybind11.readthedocs.io/en/latest/advanced.html#numpy-support" rel="nofollow">http://pybind11.readthedocs.io/en/latest/advanced.html#numpy-support</a></p>
<p>文档页。它支持缓冲区协议和numpy数组。因此,您不必执行<code>tolist</code>步骤。在</p>
<pre><code>#include <pybind11/numpy.h>
void f(py::array_t<double> array);
</code></pre>