ctsquarelib = ctypes.cdll.LoadLibrary('ctsquare.so')
ctsquarelib.mysumsquares.restype = ctypes.c_float
ctsquarelib.mysumsquares.argtypes = [c_float_p, ctypes.c_size_t]

def myssq(arr):
    arr = numpy.ascontiguousarray(arr, dtype='float32')
dataptr = arr.ctypes.data_as(c_float_p)
datasize = arr.ctypes.shape[0]
ret = ctsquarelib.mysumsquares(dataptr, datasize)
return ret
if __name__ == '__main__':
    a = numpy.array([1, 2, 3, 4])
print('sum of squares of [1,2,3,4] =', myssq(a))
Beginner extending C with Python (specifically Numpy)