Re:Making Python 100x faster with less than 100 lines of Rust
by masklinn on Thursday March 30, 2023 @04:32AM
(#35369696)
You made this assertion multiple times, but so far it’s been entirely unsupported in fact, despite TFA having made the entire code set available for you to test your hypothesis on.
[ Parent
| on HN ]
Re:Making Python 100x faster with less than 100 lines of Rust
by brahbrah on Thursday March 30, 2023 @07:46AM
(#35371169)
On Google colab
import numpy as np
import time
vals = np.random.randn(1000000, 2)
point = np.array([.2, .3])
s = time.time()
for x in vals:
np.linalg.norm(x - point) < 3
a = time.time() - s
s = time.time()
np.linalg.norm(vals - point, axis=1) < 3
b = time.time() - s
print(a / b)
~296x faster, significantly faster than the solution in the article. And my assertion was supported by nearly 20 years of numpy being a leading tool in various quantitative fields. It’s not hard to imagine that a ubiquitous tool that’s been used and optimized for almost 20 years is actually pretty good if used properly.
Re:Making Python 100x faster with less than 100 lines of Rust
by akasakahakada on Thursday March 30, 2023 @08:30AM
(#35371609)
Finally some dude knows how to use numpy properly. I wish I can upvote 5 times.
I basically raise the same question somewhere below and got downvoted LOL.
Re:Making Python 100x faster with less than 100 lines of Rust
by akasakahakada on Thursday March 30, 2023 @10:32PM
(#35381732)
350X Speed Up by rewritten in Numpy but flagged and hated.