Re:Making Python 100x faster with less than 100 lines of Rust
by jcolella on Thursday March 30, 2023 @01:21AM
(#35368398)
This is possibly one of the best written articles end-to-end I have read. Excellent job telling the story
[ Parent
| on HN ]
Re:Making Python 100x faster with less than 100 lines of Rust
by brahbrah on Thursday March 30, 2023 @04:30AM
(#35369687)
Agreed it was well written, but kinda pointless though since they could have “solved” the problem using the existing tools in a couple lines of code without any new deps. All that content annd profiling and they missed the fact that they were using numpy wrong.
Re:Making Python 100x faster with less than 100 lines of Rust
by tecleandor on Thursday March 30, 2023 @05:25AM
(#35370091)
Totally out of curiosity, could you be a bit more concrete in your posted example? I can't get it to work (I'm inexperienced with numpy and I'm messing something when translating your quick example to python)
Thanks!
Re:Making Python 100x faster with less than 100 lines of Rust
by brahbrah on Thursday March 30, 2023 @07:35AM
(#35371094)
Yea sorry that was just pseudo code. You want it in this form:
centers = np.array([
[3, 3],
[4, 4]
])
point = np.array([3.5, 3.5])
vals = centers - point
np.linalg.norm(vals, axis=1)