Summary
In this chapter, we added a third-party pip
module into our setup.py
file so that we could add another entry point that could read .yml
files. We read the .yml
file and passed the data from that file in the form of a dictionary into our Rust functions, handling the complex data structure under the PyDict
struct. We then downcasted data from our complex data structure into other Python objects and Rust data types. This gave us the power to handle a range of Python data types passed into our Rust code, giving us extra flexibility in how our Python code interacts with our Rust code.
We went one step further than complex Python data structures by accepting custom Python objects under the PyAny
struct. Once we accepted custom Python objects, we could inspect attributes and set them as and when we wanted to. We even acquired the Python GIL to create our own Python data structures to help us work with the custom Python objects passed into our Rust code. To polish off our Python...