Hacker News new | ask | show | jobs
by sametmax 3137 days ago
More perfs since you are going lower level. You are not limited by cython types or pypy git warming up. You can use the full range of c libs AND rust libs. You benefit from the cargo build tools.
1 comments

I'm not sure how different this is with Cython since you can also write C/C++ code with it, and hence use any C/C++ libraries. I say that the benefit offered by the example is more of bringing the Rust ecosystem to Python than solving performance issues.
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.
You can write very efficient Cython code but it's true that in this case, you tend to adopt a lower level code style that is very close to C/C++. Basically, you need to think about the C/C++ code that will be generated by Cython.

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?

Most of the time when a developer needs loop unrolling - numpy will work best anyway. Why does everyone always start mentioning this fact when performance is mentioned?

For example, in my case I always need high-performance code to work with strings loaded from loads of CSV files. That includes: merging strings, matching them, comparing them. Loop unrolling/SIMD would not really help here, while an ability to write safe, checked code fast - would.

On the other hand I do need the pythonic dynamics, so that's what I stick to.

yes, exactly as I said.
Total layman here, but I thought one would use Rust because it’s easier to write “safe” code with it than C/C++, while maintaining an equivalent low-level speed advantage.
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 :)