我在最低階的 ThinkPad X200 上面的執行結果
$ time python -c "print(str(reduce(lambda x, y: x + y, [i for i in range(1, 10000000+1)])))"
50000005000000
real 0m3.108s
user 0m2.654s
sys 0m0.379s
$ time python3 -c "from functools import reduce; print(reduce(lambda x, y: x + y, [i for i in range(1, 10000000+1)]))"
50000005000000
real 0m2.799s
user 0m2.408s
sys 0m0.375s
參考看看
王瑋強於 2015年7月28日星期二 UTC+8下午9時29分07秒寫道: