Mercurial > cpython-lru_cache-weakref
diff Lib/difflib.py @ 30698:3e3fd56ce595 legacy-trunk
Let library modules use the new keyword arguments for list.sort().
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Thu, 16 Oct 2003 05:53:16 +0000 |
| parents | 9ca291865f9c |
| children | 71a294bd7950 |
line wrap: on
line diff
--- a/Lib/difflib.py Thu Oct 16 03:41:09 2003 +0000 +++ b/Lib/difflib.py Thu Oct 16 05:53:16 2003 +0000 @@ -701,15 +701,11 @@ s.quick_ratio() >= cutoff and \ s.ratio() >= cutoff: result.append((s.ratio(), x)) - # Sort by score. - result.sort() - # Retain only the best n. - result = result[-n:] - # Move best-scorer to head of list. - result.reverse() - # Strip scores. - return [x for score, x in result] + # Move the best scorers to head of list + result.sort(reverse=True) + # Strip scores for the best n matches + return [x for score, x in result[:n]] def _count_leading(line, ch): """
