I am trying to write some code that creates an array in GoLang, and returns it to a python script ctypes (and some numpy). What I have got so far doesn't work, and I cannot figure out why... I would appreciate any help!
My Go code goes something like this:
func Function(physics_stuff... float64, N int ) []float64{
result := make([]float64, N)
for i:= 0; i< N; i++{
result[i] = blah....
}
return result;
}
and I am currently trying to import this functionality to python using:
from ctypes import c_double, cdll, c_int
from numpy.ctypeslib import ndpointer
lib = cdll.LoadLibrary("./go/library.so")
lib.Function.argtypes = [c_double]*6 + [c_int]
def lovely_python_function(stuff..., N):
lib.Function.restype = ndpointer(dtype = c_double, shape = (N,))
return lib.Function(stuff..., N)
This python function never returns. Other functions from the same library work just fine, but they all return a single float64 (c_double in python).