📅  最后修改于: 2022-03-11 14:47:18.509000             🧑  作者: Mango
# Size of generators is a huge advantage compared to list
import sys
n= 80000
# List
a=[n**2 for n in range(n)]
# Generator
# Be aware of the syntax to create generators, lika a list comprehension but with round brakets
b=(n**2 for n in range(n))
print(f"List: {sys.getsizeof(a)} bits\nGenerator: {sys.getsizeof(b)} bits")