def get_similarity(str1,str2,threshhold): if (str1,str2) in _cache: debug("cache hit") s = _cache[(str1,str2)] else: debug("cache miss") s = round(strings.similarity(str1,str2),1) cache_similarity(str1,str2,s) return s
def similar(str1,str2,threshhold): # !caching: only saves 3s of exec time! s = round(strings.similarity(str1,str2),1) similar= (s>=threshhold) debug("(%s,%s): %s - %s" % (similar,s,str1,str2)) return s if similar else False