Python and Rust: A Dynamic Duo with PyO3

Kesia Joies (~kesia)


6

Votes

Description:

Are you interested in knowing about how to glue Python and Rust together? You may have heard about the memory efficiency and faster performance of Rust. This can be easily integrated into your Python code.

This talk will capture your interest in PyO3 which allows you to write native Python modules from Rust. By easily importing your Rust code directly as a Python module, integration is made simple. PyO3 also handles type translations between Python and Rust and provides macros to export Rust functions to Python effortlessly.

Asynchronous programming is becoming increasingly popular, and and if you're dealing with async functions in Python or want to create Python bindings for an async Rust library, pyo3-asyncio has got you covered. It simplifies the conversion of async functions between Python and Rust. Additionally, PyO3 enables easy parallelism in Rust-only code.


Outline of Talk

  1. Overview of Python & Rust
  • Brief history of Python and Rust
  • Overview of Python's strengths
  • Highlighting Rust's advantages
  1. Demonstration of Python Performance
  • Python example
  • Memory Profiler
  • Performance
  1. What is PyO3?
  • Syntax
  • Installation steps
  • Role as a Rust binding for Python
  1. Why PyO3?
  • Comparison with other Python-Rust integration approaches
  • Other libraries
  1. Rust's Performance in Python
  • Familiarization with Rust Syntax
  • Benchmarking Python vs. PyO3-Rust performance for CPU-bound tasks
  • Real-world examples
  • Exposing Rust libraries as Python modules
  1. Asynchronous and Parallelism with PyO3
  • Overview of concurrency in Python
  • Impact of GIL on Concurrency and Parallelism in Python
  • Implementing asynchronous programming with PyO3 and Rust
  • Utilizing multi-threading and parallelism with PyO3 and Python's Global Interpreter Lock (GIL)

Prerequisites:

  1. Familiarity with Python. This is essential, as PyO3 is a Python library.
  2. Some knowledge of asynchronous programming. This is not essential, but it would be helpful to understand the basics of asynchronous programming, as PyO3 can be used to write asynchronous code.
  3. A mindset to learn Rust. This is not essential, but it would be helpful to be open to learning Rust, as PyO3 is a way to write Rust code that can be called from Python.

Speaker Info:

Kesia Mary Joies is a passionate Python developer. She enjoys leveraging logical thinking to develop software solutions that make people's lives easier. At present, she is focused on developing Strollby - a travel platform that utilises Python microservices with GraphQL backend. She was awarded the Grace Hopper Scholarship for the year 2021, awarded annually to women in Technology. Also, she was recognised recently as the Top 5 Best Women Outgoing Students from India, conducted by IEEE Pune Section and Hope Foundation India. She was a speaker in PyConf Hyderabad 2022, and embarked on her journey as an International speaker at the oldest and longest running volunteer-led Python programming conference, EuroPython Conference 2023.

Section: Concurrency
Type: Talks
Target Audience: Intermediate
Last Updated: