Live data from Hacker News

Speed up your Python using Rust

developers.redhat.com

11–20 of 102 posts

Re: Speed up your Python using Rust

#11
post #10
post #5

Earlier quoted context omitted.

Well, with cython, either you write python compiled to C, and you won't match rust perf nor types, or you write c/c++ and bind it to python, and you won't match rust safetiness.

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

#13
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 of Debian/Stable should be fine, shouldn't it? Same of Fedora, etc.

Re: Speed up your Python using Rust

#14
post #12

Speed 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.

Nim probably makes more sense if you're coming from Python.

Oh, and Python is perfectly fine for most things. If you like it, sticking with it and just speeding up the rare thing that needs that performance makes much more sense than switching language, especially if you already are well into a project.

Re: Speed up your Python using Rust

#16
post #9
post #7

Earlier quoted context omitted.

you should also quote "easier" ;) it's certainly easier once you sacrifice a goat to the compiler to stop insulting you and your mother. disclaimer: i love rust

Well it's better than your client insulting you and your mother because your software killed their goat by mistake.

lol. It's sad that I can only upvote this once :)

Re: Speed up your Python using Rust

#17
post #13

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…

Rustup is very useful for managing toolchains. For someone new to Rust, it's probably best to be familiar with it from the outset.

Re: Speed up your Python using Rust

#18
post #8

Earlier quoted context omitted.

Cython is unsafe.

It's much easier to learn Cython once you know Python. That's the biggest selling point.

But the tooling is terrible in comparison. I find rust sigificantly easier as a python developer than cython. There is so much more rust ecosystem to take advantage of.

Re: Speed up your Python using Rust

#19
post #13

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…

If you look at the way the rustup-init.sh script is written it's safe to be used with this "anti pattern". I see your objection though but unfortunately this ship has sailed, you might as well complain about websites that don't work without Javascript...

The advantage of this method is that it will work on any linux distro (and even BSD, Darwin and mingw) and you'll get the latest stable version. I don't see the advantage of using potentially outdated OS packages for installing a compiler, it's not like it's a dependency for other packages.

It also makes it easy to manage the various components of the toolchain, for instance if you later want to crosscompile for an other target, use the nightly version etc...

Re: Speed up your Python using Rust

#20
post #13

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…

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 source (and therefore "curl | sh" without https is bad). It gives exactly the same ability to execute arbitrary code on your machine as downloading an RPM/DEB does, or adding a vendor specific repo (e.g. Docker). Distro package repos probably have broader scrutiny of the contents of packages, but there are a lot of packages so how sure can you be?

Post reply on HN