python不同方法倒转一个list 的效率对比

By at • 2283次点击
admin
ol = [1, 2, 3]; nl = ol[::-1]; 0.569 usec per loop
ol = [1, 2, 3]; nl = list(ol); nl.reverse();  0.686 usec per loop
ol = [1, 2, 3]; nl = [i for i in reversed(ol)];  1.48 usec per loop
ol = [1, 2, 3]; nl = list(reversed(ol)); 2.34 usec per loop

list, python, 倒转, 效率, 方法


“ 你的代码”

php网站设计 at 2013-12-09 15:30
1
登录 后发表评论