Giving the interface a native feel with objects
Python is an object-oriented language. When we are building our Rust packages, we need to keep the friction of adoption low. The adoption of Rust packages would be better if we keep our interfaces as objects. Most Python packages have object interfaces. Calculations are done with inputs, and the Python object has a range of functions and attributes that give us the results of those calculations. While we did cover creating classes in Rust with pyo3
macros in Chapter 6, Working with Python Objects in Rust, in the Constructing our custom Python objects in Rust section, it is advised that we understand the pros and cons of doing this. We remember that classes written in Rust are faster. However, the freedom of inheritance and metaclassing with pure Python is useful. As a result, it is best to leave the construction and organization of the object interface in pure Python. Any calculations that need to be done can be done in Rust. To demonstrate...