Created
December 30, 2017 23:26
-
-
Save ramonsaraiva/9116421b9185b217726e400337406c3a to your computer and use it in GitHub Desktop.
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
from memory_profiler import profile | |
def chunks_with_list(l): | |
return [ | |
l[i:i + 100] for i in range(0, len(l), 100) | |
] | |
def chunks_with_gen(l): | |
return ( | |
l[i:i + 100] for i in range(0, len(l), 100) | |
) | |
@profile | |
def chunkify_list_with_list(): | |
l = [0] * 1000000 | |
for _ in chunks_with_list(l): | |
pass | |
@profile | |
def chunkify_list_with_gen(): | |
l = [0] * 1000000 | |
for _ in chunks_with_gen(l): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment