I'm trying to figure out what would be the best way to loop through a list, and I want to convince myself that it is effectively the fastest.
I want to compare these 3 :
for i in range(len(data)):
...
for item in data:
...
for idx,item in enumerate(data):
...
I tried to use timeit to compare these three, but I always get almost the same result. I tried printing things, creating lists, and navigating through a huge list, but I always get the same results. However, I found that there is a performance difference between 1 and 2 (Which is the most efficient way to iterate through a list in python?). I know would like to see what does enumerate do regarding efficiency, but can't find anything on it nor use my results.
Any help would be much appreciated, thanks in advance and have a nice day !