Performance: Matlab vs Python

前端 未结 5 1915
长情又很酷
长情又很酷 2020-11-29 13:06

I recently switched from Matlab to Python. While converting one of my lengthy codes, I was surprised to find Python being very slow. I

5条回答
  •  天命终不由人
    2020-11-29 13:22

    I got ~5x speed improvement over the meshgrid solution using only broadcasting:

    def exampleKernelD(M, x, N, y):
        return np.sqrt((x[:,1:] - y[:,1:].T) ** 2 + (x[:,:1] - y[:,:1].T) ** 2)
    

提交回复
热议问题