Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pumping up python module using Rust - PyCon ID ...

Pumping up python module using Rust - PyCon ID 2017

Lightning talk about how one can speed up their Python modules/lib/frameworks using Rust at Pycon Indonesia 2017.

Github: https://github.com/vigneshwerd/Rust-PyconID

vigneshwer dhinakaran

December 08, 2017

Transcript

27 slides
  1. What’s the Catch Whenever performance and control comes into the

    picture we are complacent that “ I can write a C extension ”
  2. 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)
  3. Rust : Introduction System programming language that has great control

    like C/C++, delivers productivity like in Python, and is super safe
  4. 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
  5. A bit complex example fn avg(list: &[f64]) -> f64 {

    let mut total = 0; for el in list{ total += *el; } total/list.len() as f64 }
  6. Parallel Version (Rayon) extern crate rayon; use rayon::prelude::*; fn avg(list:

    &[f64]) -> f64 { list.par_iter().sum::<f64>() / list.len() as f64 }
  7. Rust Trailheads Follow us on Twitter: @rustlang @ThisWeekInRust Join Rust

    IRC Channels: #rust #rust-community #rust-machine-learning #tensorflow-rust Join Rust Websites: rust-lang.org rustbyexample.com rustaceans.org reddit.com/r/rust/ 18
  8. ~ Ownership and Borrowing ~ Type Ownership T &T Alias?

    Mutate? Owned Shared reference ✓ ✓ &mut T Mutable reference ✓
  9. ~ Concurrency paradigms ~ Paradigm Fork-join Ownership? Borrowing? ✓ Message

    Passing Locking ✓ ✓ ✓ Lock-free Futures … ✓ ✓ ✓ ✓
  10. 22

  11. 23

  12. 27

More Decks by vigneshwer dhinakaran

Other Decks in Technology