Python 通过SWIG将简单numpy数组传递给C
我想通过SWIG将已知大小和类型的numpy数组传递给C函数Python 通过SWIG将简单numpy数组传递给C,python,c,numpy,swig,Python,C,Numpy,Swig,我想通过SWIG将已知大小和类型的numpy数组传递给C函数 # .py data = numpy.arange( N , dtype=numpy.int32 ) external_c_function( data ) # .i extern void external_c_function( int32_t* data ); # .c void external_c_function( int32_t* data) { // ... } 很遗憾,我将得到一个错误: TypeErr
# .py
data = numpy.arange( N , dtype=numpy.int32 )
external_c_function( data )
# .i
extern void external_c_function( int32_t* data );
# .c
void external_c_function( int32_t* data)
{
// ...
}
很遗憾,我将得到一个错误:
TypeError: in method 'external_c_function', argument 1 of type 'int32_t *'
将numpy数组传递给SWIG的最简单方法是什么 您可以使用
numpy.i
。看看