Light optimization

This commit is contained in:
Yomguithereal 2018-05-30 11:28:23 +02:00
parent 9e8420df63
commit fab5476720
1 changed files with 4 additions and 0 deletions

View File

@ -40,6 +40,10 @@ def weighted_jaccard_similarity(A, B, key=lambda x: x):
done = set()
# Swapping to iterate over smaller set and minimize lookups
if len(A) > len(B):
A, B = B, A
# Computing intersection
for k, v in A.items():
weight_A = key(v)