Comparing speed with Python, Rust, and Numba
We have now built a pip
module in Rust with command-line tools, Python interfaces, and unit tests. This is a shiny new tool that we have. Let's put it to the test. We know that Rust by itself is faster than Python. However, do we know that the pyo3
bindings slow us down? Also, there is another way to speed up our Python code and this is with Numba, a Python package that compiles Python code to speed it up. Should we go through all of the haste of creating the Rust package if we can achieve the same speed with Numba? In this section, we will run our Fibonacci function several times, in Python, Numba, and our Rust module. It has to be noted that Numba can be a headache to install. For instance, I could not install it on my MacBook Pro M1. I had to install Numba on a Linux laptop to run this section. You don't have to run the code in this section; it is more for demonstrative purposes. If you do want to try and run the test script...