def perf_new():
t1 = time.time()
for i in range(10000000):
s=str(UUID(b'\xbc\x99\xfe\xf6{\x0bLO\x8en\xe8\xb4\x1aC;5'))
print(1000*(time.time()-t1))
def perf_exists():
t1 = time.time()
uuids = UUID(b'\xbc\x99\xfe\xf6{\x0bLO\x8en\xe8\xb4\x1aC;5')
for i in range(10000000):
s=str(uuids)
print(1000*(time.time()-t1))
perf_exists()
Old -> 2681.8525791168213
New -> 277.8770923614502
perf_new()
Old -> 11315.203666687012
New -> 6226.833820343018
increase performance up to 10x on exists string to uuid, 2x for new.
reduce some performance for hash, but can be use just string to match in dict, just hash as UUID string
def perf_new(): t1 = time.time() for i in range(10000000): s=str(UUID(b'\xbc\x99\xfe\xf6{\x0bLO\x8en\xe8\xb4\x1aC;5')) print(1000*(time.time()-t1))
def perf_exists(): t1 = time.time() uuids = UUID(b'\xbc\x99\xfe\xf6{\x0bLO\x8en\xe8\xb4\x1aC;5') for i in range(10000000): s=str(uuids) print(1000*(time.time()-t1))
increase performance up to 10x on exists string to uuid, 2x for new. reduce some performance for hash, but can be use just string to match in dict, just hash as UUID string