[Python] python列表连接添加性能测试代码 →→→→→进入此内容的聊天室

来自 , 2019-10-16, 写在 Python, 查看 120 次.
URL http://www.code666.cn/view/ffd2257b
  1. L = [1, 2]
  2. L = L + [3]            # concatenate: slower
  3. print L
  4.  
  5. L.append(4)            # faster, but in-place
  6. print L
  7.  
  8. L = L + [5, 6]         # concatenate: slower
  9. print L
  10.  
  11. L.extend([7, 8])       # faster, but in-place
  12. print L
  13.  
  14. L += [9, 10]       # mapped to L.extend([9, 10])
  15. print L
  16.  
  17.  
  18. #//python/4504

回复 "python列表连接添加性能测试代码"

这儿你可以回复上面这条便签

captcha