Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Coursera

OO: Python to Rust

Pragmatic AI Labs via Coursera

Overview

AI, Data Science & Cloud Certificates from Google, IBM & Meta — 50% Off
One plan covers every Professional Certificate on Coursera. 50% off Coursera Plus Annual for 10 days only — price increases June 17.
Unlock All Certificates
OO: Python to Rust is a hands-on course on object-oriented design for engineers moving from Python (a class-based, dynamic OO language) to Rust (a struct-and-trait-based language with no inheritance and strict ownership). You will learn how Rust models the four classical OO pillars - encapsulation, abstraction, polymorphism, and code reuse - without classes or inheritance, using structs, methods (impl blocks), traits, trait objects, generics, enums, and the type state pattern. The course translates common Python OO patterns (dataclasses, dunder methods, ABCs, mixins, descriptors, protocols, the singleton, factory, observer, strategy, and decorator patterns) into idiomatic Rust, and explains why some of them simply don't apply once you have algebraic data types and ownership. You will refactor a non-trivial Python OO codebase into Rust, learn when composition beats inheritance, when an enum beats a class hierarchy, and how to design APIs that leverage Rust's compile-time guarantees. By the end of the course, you will be able to read OO Python code and produce a correct, idiomatic Rust translation, and justify your design decisions on a code review. Part of the Rust for Data Engineering specialization.

Syllabus

  • Three Modes of Proof for Complexity Claims
    • Every Big-O claim in this course ships with three independent receipts: an EMPIRICAL bench (criterion measures the curve), a STRUCTURAL guard (Rust types and proptest enforce it), and a FORMAL theorem (Lean 4 machine-checked, displayed as a [verified] stamp). Complexity is a CLAIM about how runtime or memory scales with input size. In this module you learn the c24 workflow: write the claim as a contract, bind it to your Rust pub item, then attach the three receipts. A CLAIM of O(N) survives only if the slope on a log-log plot stays linear from N=10 to N=1,000,000.
  • Empirical Wins — Speed You Can Measure
    • In this module you will master Empirical Wins — the speedups you can measure with cargo bench. You will translate three Python patterns to Rust idioms that drop runtime and memory: list comprehensions become fused iterator chains (filter+map in one pass, O(1) memory vs O(N)); x in dict becomes HashMap::contains_key with hasher choice as a c24 receipt (FxHash, AHash, or default SipHash, each measured); and sorted() becomes sort_unstable for cases where stability is not required. Every claim ships with criterion HTML reports as the EMPIRICAL receipt, a STRUCTURAL guard from Rust's type system, and a [verified] stamp from a FORMAL theorem.
  • Structural Wins — Correctness via Types
    • Python Optional[T] becomes Rust Option with proptest sweeping every combinator chain; Python try/except becomes Result with @semantic: total promoting every fallible function — the structural receipt that makes silent failure impossible.
  • Systems — Translation with Runtime Consequences
    • Systems-level translation makes the runtime trade-off visible. Python generators allocate per-call frame state and pay GIL overhead; Rust Iterator is monomorphized into the caller's stack — the structural receipt is the criterion bench showing a ~50x tight-loop gap. subprocess.run with sh -c re-introduces CWE-78 shell injection; Command::new().arg() invokes execve directly and removes the attack surface entirely. threading on CPython is serialized by the GIL; rayon::par_iter() distributes work across all cores via a Send + Sync work-stealing scheduler whose data-race bugs are compile errors. Each translation in this module is a runtime claim with a measurable receipt.
  • Capstone — The Three-Mode Playbook End to End
    • The capstone closes the loop with a five-step playbook — transpile, inspect, refine, bench, prove — that you can apply to any hot Python loop and ship a receipt-backed Rust translation. Every Pull Request lands four receipts: criterion HTML report, proptest run, contract pv check, and a Lean status: proved stamp. The second lesson is the inverse: when the receipt-driven math says keep Python. Breakeven analysis, BREAKEVEN.md, and a final graded quiz that synthesizes Modules 1–5.

Taught by

Noah Gift

Reviews

Start your review of OO: Python to Rust

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.