Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Iterate thru a very big list, to be used in case you iterate over a list and you get memory error
def genumerate(li):
#using a generator not to kill memory
for item in li:
yield li.index(item), item
#use case
for idx, val in genumerate(biglist):
pass #do_something()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment