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

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. Pumping Python modules using Rust PyCon Indonesia 2017 Vigneshwer Dhinakaran

    | Mozilla TechSpeaker | @dvigneshwer
  2. What’s the Catch Whenever performance and control comes into the

    picture we are complacent that “ I can write a C extension ”
  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)
  4. What’s the main ask here for us? C’s Performance, Portability

    & Embeddability With Guaranteed Safety
  5. Rust : Introduction System programming language that has great control

    like C/C++, delivers productivity like in Python, and is super safe
  6. None
  7. None
  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
  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 }
  10. HLL version fn avg(list: &[f64]) -> f64 { list.iter().sum::<f64>() /

    list.len() as f64 }
  11. Parallel Version (Rayon) extern crate rayon; use rayon::prelude::*; fn avg(list:

    &[f64]) -> f64 { list.par_iter().sum::<f64>() / list.len() as f64 }
  12. Demo Benchmarking fibonacci series

  13. Benchmarking Results

  14. where are we with Rust?

  15. 2016 -17 Rust is the Most Loved Language by Developers

  16. Friends of Rust Organizations running Rust in production. (https://www.rust-lang.org/en-US/friends.html)

  17. Resources https://github.com/vigneshwerd/Rust-PyconID Raise issues in the repository for questions?

  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
  19. Appendix

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

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

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

  23. 23

  24. 24 Gradual adoption works.

  25. 25 Community Photo credit: David McSpadden https://www.flickr.com/photos/familyclan/15535822737/

  26. 26 RFC Process

  27. 27