vendredi 5 octobre 2018

Why is numpy.random.random() so much slower than random.random()?

I'm comparing the performance of random.random() and numpy.random.random():

python -m timeit -s 'import numpy as np' 'np.random.random()'
1000000 loops, best of 3: 0.306 usec per loop

python -m timeit -s 'import random' 'random.random()'
10000000 loops, best of 3: 0.0557 usec per loop

There is a massive difference in performance. How come numpy is so much slower?




Aucun commentaire:

Enregistrer un commentaire