Numpy vs Cython speed

前端 未结 5 1528
清酒与你
清酒与你 2020-11-28 22:37

I have an analysis code that does some heavy numerical operations using numpy. Just for curiosity, tried to compile it with cython with little changes and then I rewrote it

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 22:57

    The difference may be due to version 1 and 2 doing a Python-level call to np.sum() for each row, while version 3 likely compiles to a tight, pure C loop.

    Studying the difference between version 2 and 3's Cython-generated C source should be enlightening.

提交回复
热议问题