Why is MATLAB much faster than Python for svd?

Viewed 368

I'm considering using Python for my future codes but I'm surprised by the differences in computation time.

For my example, I calculate the decomposition into singular values of a 1000x1000 random matrix, attached the two codes :

Matlab (0.38s):

M = randn(1000,1000);
[U,S,V] = svd(M);

Python (2.7s):

import numpy as np
M = np.random.randn(1000,1000)
U,S,V = np.linalg.svd(M)

Does the comparison between these two codes seem fair? I thought this type of functions were optimized in fortran/C langage for python, how is it possible that matlab is that faster in such conditions?

0 Answers
Related