分析
首先先放上,Stackflow 的高票答案的结论
A list comprehension is usually a tiny bit faster than the precisely equivalent for loop (that actually builds a list), most likely because it doesn’t have to look up the list and its append method on every iteration. However, a list comprehension still does a bytecode-level loop.
显然,列表推导比 for 循环稍快。
答者的分析为列表解析没有创造一个列表的实体,所以它的稍微的性能提升来源于不需要在每次迭代中查找列表,和使用它的 append 函数。