Ondřej Vostál - Async Python modules in Rust [PyData Prague 2022-12-13]

Discover how to utilize Rust to improve the performance of Python modules, leveraging async processing and efficient error handling to boost application speed and scalability.

Key takeaways
  • Python has a performance penalty due to abstraction and exceptions, costing around 5 nanoseconds for basic timings.
  • Rust is a modern C++ replacement, efficient and fast, potentially even faster than C++.
  • Async processing in Rust uses the Tokio framework, which is a popular choice for writing async code in Rust.
  • Rust’s error-handling model is different from Python’s, with functions returning result objects instead of throwing exceptions.
  • Pyo3 is used to create Python extensions in Rust, which provides macros and other helpful tools.
  • Python modules can be consumed from Rust using async I/O, allowing for efficient communication between the two languages.
  • Rust’s move semantics and ownership system are important to consider when working with Python objects.
  • Jill is a framework that provides a Python-like experience in Rust, allowing for easier implementation of Python-like code in Rust.
  • Errors in Rust can be handled using the ? operator, which allows a function to return early if an error is encountered.
  • Rust’s async I/O model is designed to be efficient and scalable, making it suitable for high-performance applications.
  • Chainkeepers, the company where the speaker works, uses Rust and Python for their blockchain analysis and trading bot development.
  • The speaker’s company is looking for people to work together and learn more about their projects.