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

20190409_FasterPythonMeetUp_TAMIYA

tatamiya
April 08, 2019

 20190409_FasterPythonMeetUp_TAMIYA

tatamiya

April 08, 2019
Tweet

More Decks by tatamiya

Other Decks in Technology

Transcript

  1.   u A<-26 ', )(/;0  u Scikit-learn= 7

    u @3&%!#4. +"*$(4 u For8?: 5 u → 91> 
  2. %-&  u CythonC(,* .  u CFortran !') u

    Numba0jit(just in time) $"#+ →   2 u /1&
  3. /, *  u 1 ~ N %') ($ def

    sum_from_one(k): sum = 0 for i in range(1, k+1): sum += i return sum sum_list = [] for i in range(0, N): sum_list.append(sum_from_one(i))  (N=10000) -Python 2.09 s  28.3 ms Cython 6.36 ms  62.5 µs +.#(joblib) 702 ms  21 ms MacBook Pro 13!(2018" ) &4 16GB OSmacOS Mojave 10.14.1
  4. 2"%  3  u -8<47 1#'+, u *' 0

    u 9:/ &$-5! 47 u Numpy linalg.lstsq ).% u -5@6(&$ 0'?  (N=10000) = Python 1.77 s  74.1 ms Cython 1.74 s  24.2 ms ;>#(joblib) 800 ms  20.7 ms
  5. C>Cython u  u + )2;B8-<F:0 u NumpyD41.JHCython? I MN

    u L u + )1.OpenMPKO3 u # ',G? I A67 / … *%&C9E !($ "&5= @ 
  6. (joblib) u     (N) Python (joblib) 

     103 83.9 ms  2.1 ms 107 ms  5.96 ms 0.78 104 2.09 s  28.3 ms 702 ms  21 ms 3.0 105 1min 50s  3.61 45.5 s  1.07 s 2.4
  7. ,/ u -#(Numpy 0+ . ' 25 u &4* 

      u Cython : 0+ ! %$ u 68*710+9) 3)" %$
  8.   OSS '5, u Scikit-learn&$ u 1")./*%Numpy, Scipy6# 

    u !  Cython  2 u 743+(0 OSS-