Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Rust-Python interop workshop #2556

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/services/workshops.njk
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ og:
"link": "services/workshops/authentication-for-svelte-sveltekit/"
}
%}
{%
set 'workshop_16' = {
"eyebrow": "Bookable for teams",
"title": "Rust-Python Interoperability",
"logo": "rust",
"link": "services/workshops/rust-python-interoperability/"
}
%}
{%
set workshops = [
workshop_1,
Expand All @@ -156,7 +164,8 @@ og:
workshop_12,
workshop_13,
workshop_14,
workshop_15
workshop_15,
workshop_16
]
%}
{{ techCards('workshops', 'Workshops Catalog', 'We offer a range of workshops bookable for teams that want to grow – on-site or remote. We\'re also happy to prepare custom workshops – <a href="/contact/">get in touch with us</a> to talk about what curriculum fits your team best!', workshops) }}
Expand Down
10 changes: 9 additions & 1 deletion src/services/workshops/rust.njk
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,15 @@ image: "/assets/images/workshops/rust-og-image.jpg"
"link": "services/workshops/advanced-testing-in-rust/"
}
%}
{% set workshops = [workshop_1, workshop_2, workshop_3, workshop_4, workshop_5, workshop_6] %}
{%
set 'workshop_7' = {
"eyebrow": "Bookable for teams",
"title": "Rust-Python Interoperability",
"logo": "rust",
"link": "services/workshops/rust-python-interoperability/"
}
%}
{% set workshops = [workshop_1, workshop_2, workshop_3, workshop_4, workshop_5, workshop_6, workshop_7] %}
{{
workshopsList('Our training offering', 'We specialize on Rust on the backend: API services, workers, data pipelines. That focus shapes our training offering.
We can walk alongside you on a journey from zero to hero,
Expand Down
56 changes: 56 additions & 0 deletions src/workshops/rust-python-interoperability.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: "Rust-Python Interoperability"
tags: "rust"
format: "Workshop: 1 day"
subtext: "Bookable for teams – on-site or remote"
description: >
<p>Python has served you well: you spun up a prototype and iterated quickly, keeping up with the evolving requirements of a successful product. Nonetheless, as time goes on, cracks are starting to show up: an endpoint is slower than it needs to be, a data processing job that took seconds now takes almost an hour, and your infrastructure bill is growing too fast compared to the size of your user base. Engineers are starting to whisper: is it time for a rewrite? Should we pause feature development to rebuild everything on more solid foundations? That's an option, but it's expensive.</p><p>There's another path: rather than throwing away your entire Python codebase to start over, you analyse your application and isolate the performance-critical bits—the so-called "hot modules" where your application spends most of its time. You will rewrite those in Rust and package them as a Python native extension. This workshop will teach you how.</p><p>We will cover the <code>pyo3</code> crate, the subtleties of Python's Global interpreter lock, and typical examples that may arise in your daily Rust-Python interoperability work. By the end of the session, you will be well-equipped to seamlessly replace your slow Python modules with easy-to-use and blazingly fast Rust modules.</p><p>We assume you are familiar with Rust and Python, but we don't assume any prior interoperability knowledge. We will provide a brief explanation and references whenever we rely on advanced features in either language.</p>


hero:
color: purple
image: "/assets/images/workshops/rust-python-interoperability/header-background.jpg"
imageAlt: "Close-up photo of 3 snake bodies (or 3 parts of the same snake body) stacked on top of each other."
og:
image: /assets/images/workshops/rust-python-interoperability/og-image.jpg
topics:
- title: Introduction to Rust-Python Interoperability
text: >
We kick off with looking at the advantages of combining Rust and Python, understanding where each language shines and why interoperability is valuable. This module introduces tools like <code>PyO3</code>, which enables Rust code integration within Python environments, and <code>maturin</code>, a library for building, packaging and publishing Python extensions written in Rust.


- title: Building Python Extensions in Rust
text: >
We'll continue with the process of creating Python-callable Rust functions, setting up projects using <code>PyO3</code>, and configuring the development environment to handle Rust extensions in Python.


- title: Managing Data and Types
text: >
Next, participants will learn how to handle complex data structures shared between Rust and Python, with a focus on type conversions, data ownership, and ensuring memory safety across both languages.


- title: Concurrency and the GIL
text: >
The workshop covers Python’s Global Interpreter Lock (GIL) and strategies for concurrent programming, including async programming in Rust that can enhance Python’s parallel processing capabilities.


- title: Creating Python Classes with Rust
text: >
We move on to explore creating Python-accessible classes directly in Rust using <code>PyO3</code>'s <code>#[pyclass]</code> attribute. This module teaches struct definition, implementing methods, and adding Rust-based functionality to Python classes.


- title: Static Methods and Inheritance
text: >
The final module details adding static methods to Rust-backed Python classes, along with managing inheritance and visibility in Python environments.


leads:
- name: Luca Palmieri
title: Principal Engineering Consultant
handle: algo_luca
image: /assets/images/authors/algo_luca.jpg
bio: >
Luca Palmieri builds technology products for a living. His current focus is on backend development, software architecture and the Rust programming language. He is the author of "Zero to Production in Rust".
---

<!--break-->
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading