%load_ext cythonmagic %%cython -lcblas import numpy as np cdef extern: double ddot_( int* N, double* X, int* INCX, double* Y, int* INCY ) nogil cpdef double dot(double[:] a, double[:] b) nogil: cdef int inc = 1 cdef int n = a.shape[0] return ddot_(&n, &a[0], &inc, &b[0], &inc) def main(): a = np.random.rand(100) b = np.random.rand(100) s = dot(a,b) a = np.random.rand(100) b = np.random.rand(100) %timeit dot(a,b) %timeit np.dot(a,b)