Chapter 7: Using Python Modules with Rust
We have now become comfortable with writing Python packages in Rust that can be installed using pip
. However, a large advantage of Python is that it has a lot of mature Python libraries that help us write productive code with minimal errors. This seems a legitimate observation that could halt us from adopting Rust in our Python system. However, in this chapter, we counter this observation by importing Python modules into our Rust code and running Python code in our Rust code. To achieve an understanding of this, we are going to use the NumPy Python package to implement a basic mathematical model. Once this is done, we are going to use the NumPy package in our Rust code to simplify the implementation of our mathematical model. Finally, we will evaluate the speed of both implementations.
In this chapter, we will cover the following topics:
- Exploring NumPy
- Building a model in NumPy
- Using NumPy and other Python modules in Rust...