Pumping up python module using Rust - PyCon ID 2017

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

5937108d7f8720d6e441e3c74e5fe517?s=128

vigneshwer dhinakaran

December 08, 2017
Tweet

Transcript

  1. 2.

    What’s the Catch Whenever performance and control comes into the

    picture we are complacent that “ I can write a C extension ”
  2. 3.

    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. 4.
  4. 5.

    Rust : Introduction System programming language that has great control

    like C/C++, delivers productivity like in Python, and is super safe
  5. 6.
  6. 7.
  7. 8.

    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
  8. 9.

    A bit complex example fn avg(list: &[f64]) -> f64 {

    let mut total = 0; for el in list{ total += *el; } total/list.len() as f64 }
  9. 11.

    Parallel Version (Rayon) extern crate rayon; use rayon::prelude::*; fn avg(list:

    &[f64]) -> f64 { list.par_iter().sum::<f64>() / list.len() as f64 }
  10. 18.

    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
  11. 19.
  12. 20.

    ~ Ownership and Borrowing ~ Type Ownership T &T Alias?

    Mutate? Owned Shared reference ✓ ✓ &mut T Mutable reference ✓
  13. 21.

    ~ Concurrency paradigms ~ Paradigm Fork-join Ownership? Borrowing? ✓ Message

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

    22

  15. 23.

    23

  16. 27.

    27