[Python-ideas] difflib.SequenceMatcher quick_ratio
floyd at floyd.ch
Mon Jun 8 09:56:41 CEST 2015
I use this python line quite a lot in some projects:
if difflib.SequenceMatcher.quick_ratio(None, a, b) >= threshold:
I realized that this is performance-wise not optimal, therefore wrote a
method that will return much faster in a lot of cases by using the
length of "a" and "b" to calculate the upper bound for "threshold":
if difflib.SequenceMatcher.quick_ratio_ge(None, a, b, threshold):
I'd say we could include it into the stdlib, but maybe it should only be
a python code recipe?
I would say this is one of the most frequent use cases for difflib, but
maybe that's just my biased opinion :) . What's yours?
More information about the Python-ideas