Passing complex Python objects into Rust
A key skill that enables us to take our Rust pip
module development to the next level is taking in complex Python data structures/objects and using them. In Chapter 5, Creating a Rust Interface for Our pip Module, we accepted integers. We noticed that these raw integers were just directly transferred to our Rust function. However, with Python objects, it is more complex than this.
To explore this, we will create a new command-line function that reads a .yml
file and passes a Python dictionary into our Rust function. The data in this dictionary will have the parameters needed for firing our fibonacci_numbers
and fibonacci_number
Rust functions, adding the results of those functions to the Python dictionary and passing it back to the Python system.
To achieve this, we must carry out the following steps:
- Update our
setup.py
file to support .yml
loading and a command-line function that reads it. - Define a command-line function...