Chapter 6: Working with Python Objects in Rust

So far, we have managed to fuse Rust with Python to speed up our code. However, software programs written in Rust can get complicated. While we can get by with passing integers and strings into Rust functions from Python code, it would be useful to handle more complex data structures from Python and objects. In this chapter, we accept and process Python data structures such as a dictionary. We will go further by processing custom Python objects and even creating Python objects inside our Rust code.

In this chapter, we will cover the following topics:

  • Passing complex Python objects into Rust
  • Inspecting and working with custom Python objects
  • Constructing our own custom Python objects in Rust

Get Speed Up Your Python with Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.