NumPy performance: uint8 vs. float and multiplication vs. division?

后端 未结 4 1220
暖寄归人
暖寄归人 2021-02-02 14:50

I have just noticed that the execution time of a script of mine nearly halves by only changing a multiplication to a division.

To investigate this, I have written a smal

4条回答
  •  执笔经年
    2021-02-02 15:22

    It's because you multiply an int by a float and store the result as an int. Try your arr_mult and arr_div tests with different integer or float values for the multiplication / division. Especially, compare multiplying by '2' and multiplying by '2.'

提交回复
热议问题