Calling Rust from Python: A Gentle Introduction to PyO3

Nafiul Islam (~gamesbrainiac)




Rust is rapidly gathering momentum in the Developer Ecosystem. Microsoft, Amazon and Google and starting to invest in the language. So, what’s in it for us Pythonistas? In this workshop we cover how to call Rust from Python and take advantage of the performance benefits that Rust provides. We will explore some common data structures in Rust that can be easily passed onto Python, create some small applications with notable performance gains and finally we will talk about the limitations of PyO3. We will set up our devices to be able to build and work with Rust and Python and by the end of the workshop, attendees should be able to learn more with the basic foundations covered.


  • Introduction to the topic and Speaker [3m]
  • Rust Python and You [20m]
  • Why and how did Rust come about?
  • The similarities and differences between Rust and Python
  • What is PyO3 and how does it work?
  • Questions [3m]
  • Settings up Rust and Maturin [30m-1H]
  • Small Break [15m]
  • Setting up PyO3 Tutorial [10m]
  • PyO3 Task 0: (Guided) Import the Vector Addition as a function in Python [10m]
  • PyO3 Task 1: (Guided) Building a Word Counter [5-10m]
  • PyO3 Task 2: Sieve of Eratosthenes [30m]
  • PyO3 Task 2.5: Apply Gaussian Blur to an Image [5-10m] <- Learning about Crates
  • PyO3 Task 3: Generate ASCII Art from an Image [35m]
  • Conclusion [3-5 minutes]


Please install Rust on your machines before coming to the workshop.

Speaker Info:

Nafiul Islam is a Software Engineer, Speaker and Author. With more than a decade of development experience, Nafiul loves talking about developer experience and how to make it better. Nafiul currently works at Sonar as the Developer Advocate for Python. Previously, he worked at JetBrains and Microsoft.

Speaker Links:

Section: Other
Type: Workshops
Target Audience: Intermediate
Last Updated: