私信  •  关注

user377964

user377964 最近创建的主题
user377964 最近回复了
13 年前
回复了 user377964 创建的主题 » 如何通过一个简单的循环获得非常快的python

将列表理解与psyco一起使用会适得其反。

此代码:

 count = 0
 for l in sys.stdin:
     count += not int(l)%k

跑的速度是原来的两倍

count = sum(not int(l)%k for l in sys.stdin)

使用psyco时。