如何将类型为'int *'的swig对象转换为ctypes int *

如何将类型为'int *'的swig对象转换为ctypes int *

问题描述:

我使用Python来处理一些数据(int数组)。这是非常缓慢。所以我把处理函数放在一个c ++ DLL中,并通过ctypes与它谈。数据从swig-wrapped模块(c ++)加载。我浏览几乎到处,但发现没有任何东西将类型int *指针的swig对象转换为ctypes int指针。我该如何做?

I was using Python to process some data (int array). It is very slow. So I put the processing function in a c++ DLL and talk with it through ctypes. The data are loaded from swig-wrapped modules (c++). I browsed almost everywhere but found nothing to convert swig object of type 'int *' pointer to ctypes int pointer. How can I do it?

感谢

解决方案这样做后几次尝试。解决这个问题的一个简单方法是使用SWIG封装c ++代码,因此可以将其传递给其他SWIG封装的模块。

It seems no solution to do that after a few attempts. A simple way to fix this problem is wrapping the c++ code with SWIG, so can pass it to other SWIG-wrapped modules.