# Feature or enhancement ### Proposal: 1. `s.ratio()` is calculated twice ```python def get_close_matches(...): ... for x in possibilities: s.set_seq1(x) if s.real_quick_ratio() >= cutoff and \ s.quick_ratio() >= cutoff and \ s.ratio() >= cutoff: result.append((s.ratio(), x)) ... ``` 2. `avail.__contains__` is slower than `in` operator ``` def quick_ration(self): ... availhas, matches = avail.__contains__, 0 for elt in self.a: if availhas(elt): numb = avail[elt] ... ``` ### Has this already been discussed elsewhere? This is a minor feature, which does not need previous discussion elsewhere ### Links to previous discussion of this feature: _No response_ <!-- gh-linked-prs --> ### Linked PRs * gh-142940 <!-- /gh-linked-prs -->
Activity
gh-142939: difflib.get_close_matches performance (#142940)
tim-one commentedon Dec 31, 2025
The linked P:R was merged, #142940, so closing this.
pythongh-142939: difflib.get_close_matches performance (python#142940)