1000 万直接放内存里面,单线程 1000 万次比较 0.36s: ```python import string import random # initializing size of string N = 16 data = set() for i in range(10000*1000): data.add(''.join(random.choices(string.ascii_letters, k=N)))
start=time.time() sample = ''.join(random.choices(string.ascii_letters, k=N)) for _ in range(10000*1000): if sample in data: pass end=time.time() print("set:", end-start) ```