I like the article, but the following advice confused me, especially since this comes from RedHat i.e. Linux people: > Having Rust installed (recommended way is https://www.rustup.rs/ ). This essentially recommends unconditionally using the "curl | sh" anti-pattern. Shouldn't they recommend instead e.g. "apt-get install rustc" for Debian users? Since this doesn't make use of too recent Rust features, using Rust 1.14…
Speed up your Python using Rust
21–30 of 102 posts
Re: Speed up your Python using Rust
#22Earlier quoted context omitted.
why would rust have better performance than cython? cython is as fast as C
Cython just transpiles to C. It's not "as fast as C", it's as fast as the runtime support structures it uses, and the communication with Python allows.
Re: Speed up your Python using Rust
#23I like the article, but the following advice confused me, especially since this comes from RedHat i.e. Linux people: > Having Rust installed (recommended way is https://www.rustup.rs/ ). This essentially recommends unconditionally using the "curl | sh" anti-pattern. Shouldn't they recommend instead e.g. "apt-get install rustc" for Debian users? Since this doesn't make use of too recent Rust features, using Rust 1.14…
That is a RedHat developer blog. Is rust available on RHEL already? Looking at CentOS (which should have nearly the same packages), it doesn't appear to be available yet.
Re: Speed up your Python using Rust
#24Earlier quoted context omitted.
why would rust have better performance than cython? cython is as fast as C
Cython just transpiles to C. It's not "as fast as C", it's as fast as the runtime support structures it uses, and the communication with Python allows.
C/C++ compilers might be able to generate more optimized native code than what rutsc does though. Actually, this is a question: how good is rustc with numerical / math intensive code? For instance, does it implements loop unrolling and SIMD vectorization?
Re: Speed up your Python using Rust
#25I like the article, but the following advice confused me, especially since this comes from RedHat i.e. Linux people: > Having Rust installed (recommended way is https://www.rustup.rs/ ). This essentially recommends unconditionally using the "curl | sh" anti-pattern. Shouldn't they recommend instead e.g. "apt-get install rustc" for Debian users? Since this doesn't make use of too recent Rust features, using Rust 1.14…
Rust is a language in active development, continually getting improvements and new features. Using Rustup is the best way of managing up to date toolchains (and multiple toolchain versions if you have to). It's no harder than apt-get install, and sets the best practice early on so that someone doesn't get confused and have to switch later. "curl | sh" is only an anti-pattern in the sense that you have to trust the so…
Re: Speed up your Python using Rust
#26https://github.com/martinxyz/rust-python-example/commit/f8e3...
Re: Speed up your Python using Rust
#27Speed up your python by not using python at all. Learn a language that compiles to native binaries and be better off for it. For example: Go, Swift, D.
Re: Speed up your Python using Rust
#28This in numpy gets a better relative boost on my machine YMMV.
import numpy
def count_double_chars_np(val):
ng=np.fromstring(val,dtype=np.byte)
return np.sum(ng[:-1]==ng[1:])
def test_np(benchmark):
benchmark(count_double_chars_np, val)Re: Speed up your Python using Rust
#29For comparison, I just implemented the same as C SWIG extension[1]. It's about 10% faster, but it's cheating by comparing bytes instead of utf-8 encoded characters. The more interesting part to me is the comparison of the amount of boilerplate code required. https://github.com/martinxyz/rust-python-example/commit/f8e3...
Re: Speed up your Python using Rust
#30For comparison, I just implemented the same as C SWIG extension[1]. It's about 10% faster, but it's cheating by comparing bytes instead of utf-8 encoded characters. The more interesting part to me is the comparison of the amount of boilerplate code required. https://github.com/martinxyz/rust-python-example/commit/f8e3...
I would love to see people showing how to do simple string processing, like counting characters in proper grapheme cluster level in their favorite programming language.