CPP extension vs Cython vs CPython on calculating the mean of numpy array

Python
スポンサーリンク
test_mean (__main__.TestFasterNumpy) ... ## benchmarker:         release 4.0.1 (for python)
## python version:      2.7.12
## python compiler:     GCC 5.4.0 20160609
## python platform:     Linux-4.4.0-62-generic-x86_64-with-debian-stretch-sid
## cpu model:           Intel(R) Core(TM) i7-3517U CPU @ 1.90GHz  # 2799.937 MHz
## parameters:          loop=100000, cycle=1, extra=0

##                                                      real    (total    = user    + sys)
numpy.mean                                            1.3785    1.3800    1.3800    0.0000
faster_numpy.cython.mean                              0.2032    0.2100    0.2000    0.0100
faster_numpy.clibrary.mean                            0.1355    0.1300    0.1300    0.0000
faster_numpy.clibrary.mean partial                    0.1705    0.1700    0.1700    0.0000

## Ranking                                              real
faster_numpy.clibrary.mean                            0.1355  (100.0) ********************
faster_numpy.clibrary.mean partial                    0.1705  ( 79.5) ****************
faster_numpy.cython.mean                              0.2032  ( 66.7) *************
numpy.mean                                            1.3785  (  9.8) **

## Matrix                                               real    [01]    [02]    [03]    [04]
[01] faster_numpy.clibrary.mean                       0.1355   100.0   125.8   149.9  1017.0
[02] faster_numpy.clibrary.mean partial               0.1705    79.5   100.0   119.2   808.3
[03] faster_numpy.cython.mean                         0.2032    66.7    83.9   100.0   678.4
[04] numpy.mean                                       1.3785     9.8    12.4    14.7   100.0

ok

----------------------------------------------------------------------
Ran 1 test in 1.900s

I’d like to get any feedback to make cython faster like c extension.

コメント

タイトルとURLをコピーしました