I think this will be slow. I think you want to define a ufunc (```np.frompyfunc```).