NumPy ndarray.all() vs np.all(ndarray) vs all(ndarray)

前端 未结 3 1696
夕颜
夕颜 2021-02-20 17:06

What is the the difference between the three \"all\" methods in Python/NumPy? What is the reason for the performance difference? Is it true that ndarray.all() is always the fast

3条回答
  •  情书的邮戳
    2021-02-20 17:23

    I suspect that numpy's functions do more to evaluate an array element as a boolean, likely in some generic numeric-first way, while the builtin all() does nothing, since the elements are already booleans.

    I wonder how different the results would be with integers of floats.

提交回复
热议问题