Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created May 16, 2020 20:28
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 aniruddha27/554e8d77850d7776d2ca07a7e1540eb1 to your computer and use it in GitHub Desktop.
Save aniruddha27/554e8d77850d7776d2ca07a7e1540eb1 to your computer and use it in GitHub Desktop.
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