# 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
Generator: {sys.getsizeof(b)} bits")
def generador():
n = 1
yield n
n += 1
yield n
n += 1
yield n
for i in generador():
print(i)
# Salida: 1, 2, 3