Skip to content

SmitSanghvi94/Speed-up-your-Python-with-Rust

 
 

Repository files navigation

Speed Up Your Python with Rust

Speed Up Your Python with Rust

This is the code repository for Speed Up Your Python with Rust , published by Packt.

Optimize Python performance by creating Python pip modules in Rust with PyO3

What is this book about?

Python has made software development easier, but it falls short in several areas including memory management that lead to poor performance and security. Rust, on the other hand, provides memory safety without using a garbage collector, which means that with its low memory footprint, you can build high-performant and secure apps relatively easily. However, rewriting everything in Rust can be expensive and risky as there might not be package support in Rust for the problem being solved. This is where Python bindings and pip come in.

This book covers the following exciting features:

  • Explore the quirks of the Rust programming language that a Python developer needs to understand to code in Rust
  • Understand the trade-offs for multiprocessing and thread safety to write concurrent code
  • Build and manage a software project with cargo and crates
  • Fuse Rust code with Python so that Python can import and run Rust code
  • Deploy a Python Flask application in Docker that utilizes a private Rust pip module
  • Inspect and create your own Python objects in Rust

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders. For example, Chapter02.

The code will look like the following:

use std::error::Error;
use std::fs::File;
use csv;
use super::structs::FootPrint;
let code = "5 + 6";
let result = py.eval(code, None, Some(&locals)).unwrap();
let number = result.extract::<i32>().unwrap();

Following is what you need for this book: This book is for Python developers who want to speed up their Python code with Rust and implement Rust in a Python system without altering the entire system. You'll be able to learn about all topics relating to Rust programming. Basic knowledge of Python is required to get the most out of this book.

With the following software and hardware list you can run all code files present in the book (Chapter 1-11).

Software and Hardware List

Chapter Software required OS required
1 Python 3 Windows, Mac OS X, and Linux (Any)
1 Rust Windows, Mac OS X, and Linux (Any)
1 Docker Windows, Mac OS X, and Linux (Any)
1 PYO3 Windows, Mac OS X, and Linux (Any)
1 Redis Windows, Mac OS X, and Linux (Any)
1 PostgreSQL Windows, Mac OS X, and Linux (Any)

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Related products

Get to Know the Author

Maxwell Flitton is a software engineer who works for the open source financial loss modeling foundation OasisLMF. In 2011, Maxwell achieved his Bachelor of Science degree in nursing from the University of Lincoln, UK. While working 12-hour shift s in the A&E departments of hospitals, Maxwell obtained another degree in physics from the Open University in the UK and then moved on to another milestone, with a postgraduate diploma in physics and engineering in medicine from UCL in London. He's worked on numerous projects such as medical simulation soft ware for the German government and supervising computational medicine students at Imperial College London. He also has experience in financial tech and Monolith AI.

Other books by the authors

Rust Web Programming

About

Speed up your Python with Rust, published by Packt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 58.5%
  • Rust 37.1%
  • Dockerfile 2.2%
  • Mako 1.4%
  • Shell 0.8%