Skip to content

Instantly share code, notes, and snippets.

@PhilMarsh
PhilMarsh / dict_perf.py
Last active April 1, 2024 15:27
Investigate effect of size on Python dict construction times. Expanding on https://gist.github.com/hofrob/ad143aaa84c096f42489c2520a3875f9
import random
import string
import time
values = []
for i in range(50):
values.append("".join(random.choices(string.ascii_letters + string.digits, k=10)))
n = 500000
print(f"Construct {n=} dicts with these random values: {values=}")