- 2025-07-14 –, Club H
- 2025-07-14 –, Club H
All times in Europe/Prague In this workshop, we will cover the very basic of using PyO3 - rust library that package rust crates into Python modules. This is the most popular tool in terms of creating Python libraries with Rust. In recent years, Rust has been getting more and more popular over other similar programming languages like C and C++ due to its robust compiler checking and ownership rules to make sure memory is safe. Hence there are more and more Python libraries that have been written in Rust natively with a Python API interface. One of the tools that have been driving this movement is PyO3, a toolset that proves Rust bindings for Python and tools for creating native Python extension modules. In this interactive workshop, we will cover the very basics of using PyO3. There will be hands-on exercises to go from how to set up the project environment to writing a "toy" Python library written in Rust using PyO3. We will cover a lot of expectations of the API provided by PyO3 to create Python functions, modules, handling errors and converting types. To give developers who are not familiar with PyO3 an introduction to PyO3 so they can consider building their Python libraries with Rust to make use of Rust's memory-safe property and parallelism ability. Any developers who are interested in developing Python libraries using Rust. It will be an advantage if the attendees are comfortable writing in Rust. However, attendees are not required to be familiar with Rust as all the Rust codes will be provided. Basic knowledge of Python will be assumed from the attendees. In this workshop we recommend using Unix OS (Mac or Linux). If you use Windows, you may encounter problems with Rust and Maturin. To minimise issues that you may encounter, please go through the extra checklist below: Note: the last command is needed as If you want to start from scratch and write your own module, you can start a new project by Part 1 - introduction and getting started (40 mins) Break (15 mins) Part 2 - Creating a simple Python library (100 mins)Goal
Target audiences
Preflight checklist
Windows checklist
Setting up
mkdir pyo3_101
cd pyo3_101
uv venv .venv
source .venv/bin/activate
uv pip install maturin
python -m ensurepip --default-pip
maturin develop
cannot find pip otherwisematurin init
Outline
- What's the difference between Rust and Python (5 mins)
- Why using PyO3 (5 mins)
- Setting up the environment (exercises) (15 mins)
- Starting a new project (exercises) (15 mins)
- Creating Python modules (exercises) (40 mins)
- Generating documentation
- Creating Python functions (exercises) (60 mins)
- How to create function signatures
- How to deal wi
Intermediate
After having a career as a Data Scientist and Developer Advocate, Cheuk dedicated her work to the open-source community. Currently, she is working as AI developer advocate for JetBrains. She has co-founded Humble Data, a beginner Python workshop that has been happening around the world. She has served the EuroPython Society board for two years and is now a fellow and director of the Python Software Foundation.