Does enumeration enumerate its argument?

If I use the enumeration during iteration through a very large list of graph clusters, I want to make sure that I do not unnecessarily create any copies of this list in memory.

I tried to confirm that he would not make any copies, but would like to know for sure.

for i, cluster in enumerate(c): # code that does stuff with i and cluster 
+2
python enumerate
source share
1 answer

No, it is not. It lazily repeats the iterability that you go through when the cycle is executed.

+8
source share

All Articles