admin avatar

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

🕝 by admin

1
2
3
4
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

💘 相关文章

评论

共1条关于"python不同方法倒转一个list 的效率对比"的评论

写一条评论

Based on Golang + fastHTTP + sdb | go1.17.1 Processed in 2ms