3 回答

TA贡献1824条经验 获得超8个赞

TA贡献1810条经验 获得超4个赞
python -mtimeit -s 'd=range(10**7)' '5*10**6 in d'
10个循环,最佳每循环3:64.2毫秒 python -mtimeit -s 'd=dict.fromkeys(range(10**7))' '5*10**6 in d'
10000000个循环,每个循环3:0.0759 usc。 python -mtimeit -s 'from sets import Set; d=Set(range(10**7))' '5*10**6 in d'
1000000个循环,每个循环3:0.262 usc。

TA贡献1831条经验 获得超4个赞
速度
记忆
添加回答
举报