4 ms·
Yeah, an all-numpy version runs in less than 1ms on my M1 air import numpy as np l = 10_000 t = np.empty(l, dtype=np.float32) j = np.arange(l) t = 0.
by bscottmay 3y ago
Yeah, an all-numpy version runs in less than 1ms on my M1 air
import numpy as np
l = 10_000
t = np.empty(l, dtype=np.float32)
j = np.arange(l)
t = 0.02 \* j
t *= (0.03 * j)
t -= (0.04 \* j)
t /= 0.05 \* (j + 1)
- Twirrim 3y agoSo rather than spend 10-20 minutes reading about numpy, the author wrote 3 other implementations...? The fact that they ran the C code without the optimisation flags and compared it that way makes me think Javascript was what they actually wanted to write this one in anyway.
- Etheryte 3y agoThe author, by the looks of it from the article, is a uni student. Rather than straw-manning this into a language war, we should laude the fact that they managed to write the same thing in a number of different languages to begin with.