Using python scipy.weave inline with ctype variables?

I am trying to pass a ctype variable to inline c code using scipy.weave.inline. It would seem that it would be simple. The documentation is good at executing the usual types of python objects, however they have a lot more features than I need, and it makes more sense for me to use ctypes when working with C. I am not sure, however, where my error is.

from scipy.weave import inline from ctypes import * def test(): y = c_float()*50 x = pointer(y) code = """ #line 120 "laplace.py" (This is only useful for debugging) int i; for (i=0; i < 50; i++) { x[i] = 1; } """ inline(code, [x], compiler = 'gcc') return y output = test() pi = pointer(output) print pi[0] 
+4
source share
1 answer

scipy.weave doesn't know anything about ctypes. Inputs are limited to most basic built-in types, numpy arrays, wxPython objects, VTK objects, and wrapped SWIG objects. However, you can add your own converter code. Currently, there is little documentation on this issue, but you can look at the SWIG implementation as an instructive example.

+4
source

All Articles