from ctypes import * so = CDLL("pointerlib.so") # Set up interfaces so.mean.argtypes= [POINTER(c_double), c_int] so.mean.restype = c_double so.sum.argtypes = [POINTER(c_double), c_int] so.sum.restype = c_double # Call the functions. def cmean(dlist): doubleArray = c_double*len(dlist) # Data Type (double[n]) cx = doubleArray(*dlist) # Actual array n = len(cx) # Length of the data result = so.mean(cx, n) return float(result) def csum(dlist): doubleArray = c_double*len(dlist) cx = doubleArray(*dlist) n = len(cx) result = so.sum(cx, n) return float(result) # We can now use the functions as if they were pure python! data = [1,2,3,4,5,6] print cmean(data) print csum(data)