Created
May 16, 2020 20:28
-
-
Save aniruddha27/554e8d77850d7776d2ca07a7e1540eb1 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
import sys | |
# list comprehension | |
mylist = [i for i in range(10000000)] | |
print('Size of list in memory',sys.getsizeof(mylist)) | |
# generator expression | |
mygen = (i for i in range(10000000)) | |
print('Size of generator in memory',sys.getsizeof(mygen)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment