Created
May 9, 2018 05:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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