The easiest way to speed up Python with Rust
If you want to speed up some existing Python code, writing a compiled extension in Rust can be an excellent choice:
- In many situations, Rust code can run much faster than Python.
- Rust prevents most of the memory-management bugs that often occur in C, C++, and Cython code.
- There is a growing ecosystem of third-party Rust packages available, and unlike C and C++ it also has a built-in package manager and build system.
However, if you just want to prototype a Rust extension, packaging and integration boilerplate can get in the way: every extra bit of friction prevents you from just doing the experiment of whether or not Rust will help.
This is where rustimport
comes in, a library that makes standalone Rust files easily