4 ms·
That's why you don't use pure python for this. Here is your test done using numpy import numpy as np %timeit sum(np.sum(np.random.randint(0, 10000000,
by lqdc13 11y ago
That's why you don't use pure python for this.
Here is your test done using numpy
import numpy as np
%timeit sum(np.sum(np.random.randint(0, 10000000, 5000)) for i in range(5000))
1 loops, best of 3: 586 ms per loop
- Beltiras 11y agoI was mostly getting a comparison between cpython and pypy, less concerned with numpy vs cpython.
- lqdc13 11y agoSure, but my point is that it's not a relevant comparison. A relevant comparison is counting words or something like that. Things people don't have an easy way to do much faster.