Skip to content

Instantly share code, notes, and snippets.

@stephengruppetta
Created January 6, 2024 12:02
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 stephengruppetta/4d8f8d11dabfee1fe08c28676e11955d to your computer and use it in GitHub Desktop.
Save stephengruppetta/4d8f8d11dabfee1fe08c28676e11955d to your computer and use it in GitHub Desktop.
import random
from array import array
numbers_list = [random.randint(-1000, 1000) for _ in range(1_000_000)]
numbers_array = array("i", numbers_list)
# Let's look at the size of the list and array
import sys
sys.getsizeof(numbers_list)
# 8448728
sys.getsizeof(numbers_array)
# 4000080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment