如何分别从 numpy 和 scipy 导入阶乘函数以查看哪个更快?
我已经通过 import math 从 python 本身导入了阶乘。但是,它不适用于 numpy 和 scipy。
最佳答案
您可以像这样导入它们:
In [7]: import scipy, numpy, math
In [8]: scipy.math.factorial, numpy.math.factorial, math.factorial
Out[8]:
(<function math.factorial>,
<function math.factorial>,
<function math.factorial>)
scipy.math.factorial
和 numpy.math.factorial
似乎只是 math.factorial
的别名/引用,即is scipy.math.factorial is math.factorial
和 numpy.math.factorial is math.factorial
都应该给出 True
。
关于python - numpy 和 scipy 中的阶乘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21753841/