<分区>
我有一个疑问,为什么python的数值计算非常快? 例如下面的代码运行不到一秒
import math
print math.factorial(10000)
为什么???
标签 python
<分区>
我有一个疑问,为什么python的数值计算非常快? 例如下面的代码运行不到一秒
import math
print math.factorial(10000)
为什么???
最佳答案
math
module's functions在 C 中实现:
It provides access to the mathematical functions defined by the C standard.
通过使用 C 语言中的高效算法,您可以快速获得结果。
如果您要问为什么这个特定操作如此之快,请参阅 Why is math.factorial much slower in Python 2.x than 3.x?和 C code itself .
关于python - 为什么 python math.factorial(x) 非常快?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11313998/