Pumping Python
modules using Rust
PyCon Indonesia 2017
Vigneshwer Dhinakaran | Mozilla TechSpeaker | @dvigneshwer
Slide 2
Slide 2 text
What’s the Catch
Whenever performance and control comes into the picture
we are complacent that “ I can write a C extension ”
Slide 3
Slide 3 text
What’s the Catch
Not many us write C
extension in reality
Writing C
extension is scary
& painful
The community is
awesome we
already have such
libraries
cpython (C - 33% ) numpy (C - 53%) HeartBleed (OpenSSL bug)
Slide 4
Slide 4 text
What’s the main ask here for us?
C’s Performance, Portability & Embeddability
With Guaranteed Safety
Slide 5
Slide 5 text
Rust : Introduction
System programming language that has great control like C/C++,
delivers productivity like in Python, and is super safe
Slide 6
Slide 6 text
No content
Slide 7
Slide 7 text
No content
Slide 8
Slide 8 text
What does it offer?
➔ Strong safety guarantees
◆ No seg-faults
◆ No data-races
◆ Expressive type system
➔ Zero cost abstraction
◆ Without compromising on performance.
➔ Stability without stagnation
➔ Libraries & tools ecosystem
Goal:
Confident & productive systems programming
Slide 9
Slide 9 text
A bit complex example
fn avg(list: &[f64]) -> f64 {
let mut total = 0;
for el in list{
total += *el;
}
total/list.len() as f64
}
Slide 10
Slide 10 text
HLL version
fn avg(list: &[f64]) -> f64 {
list.iter().sum::() / list.len() as f64
}
Slide 11
Slide 11 text
Parallel Version (Rayon)
extern crate rayon;
use rayon::prelude::*;
fn avg(list: &[f64]) -> f64 {
list.par_iter().sum::() / list.len() as f64
}
Slide 12
Slide 12 text
Demo
Benchmarking fibonacci series
Slide 13
Slide 13 text
Benchmarking Results
Slide 14
Slide 14 text
where are we with
Rust?
Slide 15
Slide 15 text
2016 -17
Rust is the Most Loved Language by Developers
Slide 16
Slide 16 text
Friends of Rust
Organizations running Rust in production.
(https://www.rust-lang.org/en-US/friends.html)
Slide 17
Slide 17 text
Resources
https://github.com/vigneshwerd/Rust-PyconID
Raise issues in the repository for questions?