标签: python enumerate
如果我在迭代一个非常大的图形集群列表时使用枚举,我想确保我不会在内存中不必要地创建此列表的任何副本。
我一直在努力确认它不会创建任何副本,但想肯定地知道。
for i, cluster in enumerate(c): # code that does stuff with i and cluster
答案 0 :(得分:10)
不,它没有。它懒洋洋地迭代你在循环执行时传入的迭代。