Commit 70797194 authored by Raymond Hettinger's avatar Raymond Hettinger

Issue 11802: filecmp cache was growing without bound.

parent 6ddefd79
...@@ -48,11 +48,12 @@ def cmp(f1, f2, shallow=True): ...@@ -48,11 +48,12 @@ def cmp(f1, f2, shallow=True):
if s1[1] != s2[1]: if s1[1] != s2[1]:
return False return False
result = _cache.get((f1, f2)) outcome = _cache.get((f1, f2, s1, s2))
if result and (s1, s2) == result[:2]: if outcome is None:
return result[2]
outcome = _do_cmp(f1, f2) outcome = _do_cmp(f1, f2)
_cache[f1, f2] = s1, s2, outcome if len(_cache) > 100: # limit the maximum size of the cache
_cache.clear()
_cache[f1, f2, s1, s2] = outcome
return outcome return outcome
def _sig(st): def _sig(st):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment