Skip to content

Instantly share code, notes, and snippets.

@ClimenteA
Created May 9, 2018 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ClimenteA/bd4c9335805220f25618328400331e19 to your computer and use it in GitHub Desktop.
Save ClimenteA/bd4c9335805220f25618328400331e19 to your computer and use it in GitHub Desktop.
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