python不同方法倒转一个list 的效率对比
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
0
See Also
Nearby
- 上一篇 › pytyrant-timeout.patch
- 下一篇 › 是不是不能删除帖子的?
“ 你的代码”