Live data from Hacker News

Optimized Rust is Still Slower Than Python+NumPy

github.com

11–15 of 15 posts

Re: Optimized Rust is Still Slower Than Python+NumPy

#11
post #6

Ah, the classic problem with benchmarking programming languages. There may be further optimizations you can do to the Rust code, likewise for Python. I do find it a bit hilarious we are "comparing" Python and Rust because really what this "comparison" lets us conclude is "FFI-ing into a mature Fortran library happens to give faster numerical perf than some Rust solution that is naive in comparison." Let's see how Rus…

The most useful comparison is between implementations of each ecosystem‘s best practices.

Re: Optimized Rust is Still Slower Than Python+NumPy

#12
This shows a 7x speedup over the "done wrong" code.

Rust called into from Python showed a 100x improvement over the "done wrong" code: https://ohadravid.github.io/posts/2023-03-rusty-python/

So Python+NumPy is significantly slower than Python+Rust. And that's without doing any SIMD in the Rust code, though it's possible the compiler autounrolls and then autovectorizes the loop.

Re: Optimized Rust is Still Slower Than Python+NumPy

#14
Walkthrough:

There is a post today demonstrated that rewriting Python Code in Rust got 100X speed up.

https://news.ycombinator.com/item?id=35367520

(credit to EwanToo, who gave the link first)

Also the original author claimed that Numpy is not worth the effort because it is significantly slower.

So here is the demonstration of a piece of Numpy code, with 350X speed up over the original code.

tldr:

original Python: 1X

original Numpy: 7X

original Rust: 100X

new Numpy: 350X

Re: Optimized Rust is Still Slower Than Python+NumPy

#15
post #12

This shows a 7x speedup over the "done wrong" code. Rust called into from Python showed a 100x improvement over the "done wrong" code: https://ohadravid.github.io/posts/2023-03-rusty-python/ So Python+NumPy is significantly slower than Python+Rust. And that's without doing any SIMD in the Rust code, though it's possible the compiler autounrolls and then autovectorizes the loop.

Never mind, I read the numbers wrong.
Post reply on HN