'Differ','IS_CHARACTER_JUNK', 'IS_LINE_JUNK', 'context_diff',
'unified_diff']
+import heapq
+
def _calculate_ratio(matches, length):
if length:
return 2.0 * matches / length
result.append((s.ratio(), x))
# Move the best scorers to head of list
- result.sort(reverse=True)
+ result = heapq.nlargest(result, n)
# Strip scores for the best n matches
- return [x for score, x in result[:n]]
+ return [x for score, x in result]
def _count_leading(line, ch):
"""