It is not possible to see any justification for the code you provided.
The only thing I can think of is that the objects in links may be large or otherwise associated with limited resources, and therefore it may be important to free them as soon as possible (instead of waiting until the end of the loop to free them). But (a) if so, it would be better to process each link as it is created (possibly using a generator to organize the code), instead of creating the entire list of links before proceeding with its processing; and (b) even if you had no choice but to create the entire list before processing it, it would be cheaper to clear each entry in the list than to pop up the list:
for i, link in enumerate(links): links[i] = None ...
(The output of the first element from a list with n elements takes O (n), although in practice it will be pretty fast, because it is implemented using memmove .)
Even if you absolutely insisted that the list reappear as it repeats over it, it would be better to write a loop like this:
while links: link = links.pop(0) ...
source share