Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个问题,为什么python数值计算非常快?例如下面的代码运行时间少于一秒
import math print math.factorial(10000)
为什么???
该math模块的功能在 C 中实现:
math
它提供对 C 标准定义的数学函数的访问。
通过在 C 中使用高效的算法,您可以获得快速的结果。
如果您问为什么这个特定的操作如此之快,那么请参阅为什么 Python 2.x 中的 math.factorial 比 3.x 慢得多?和C 代码本身。