Optimize a Python code snippet to make it run faster.
import random

def generate_numbers(n):
 numbers = []
 for _ in range(n):
 numbers.append(random.randint(1, 1000))

 return numbers
import random

def generate_numbers(n):
 numbers = [random.randint(1, 1000) for _ in range(n)]

 return numbers