numpy float: 10x slower than builtin in arithmetic operations?

前端 未结 8 1054
别跟我提以往
别跟我提以往 2020-12-01 05:00

I am getting really weird timings for the following code:

import numpy as np
s = 0
for i in range(10000000):
    s += np.float64(1) # replace with np.float32         


        
8条回答
  •  醉酒成梦
    2020-12-01 05:45

    If you're after fast scalar arithmetic, you should be looking at libraries like gmpy rather than numpy (as others have noted, the latter is optimised more for vector operations rather than scalar ones).

提交回复
热议问题