2022年 11月 4日

python的运行效率到底怎么样_python运行效率真的这么低吗?

以前只听说python运行效率低,但没实际测试过,今天和asp实际对比了一下,代码如下: python:

import time

print time.localtime() num=0 while num<10000: num=num+1 print num print time.localtime()

asp:

response.Write(time()) num=0 while num<=10000 num=num+1 response.Write(num&”
“) wend response.Write(time())

测试结果如下: python开始时间:(2018, 1, 11, 14, 29, 6, 2, 166, 0) 结束时间:(2018, 1, 11, 14, 29, 55, 2, 166, 0) asp开始时间:14:37:35 结束时间:14:37:35

都是10000的循环,asp连1秒都用上,而python竟然用了49秒,这差距也太大了吧!!

如果python真的运行效率这么低,拿他作为主要编程语言还真是个问题。