Issue 11802: filecmp cache was growing without bound.

This commit is contained in:
Raymond Hettinger 2011-06-25 17:14:53 +02:00
parent fd1cb59618
commit 2c316a3e29
2 changed files with 9 additions and 5 deletions

View file

@ -48,11 +48,12 @@ def cmp(f1, f2, shallow=1):
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) if len(_cache) > 100: # limit the maximum size of the cache
_cache[f1, f2] = s1, s2, outcome _cache.clear()
_cache[f1, f2, s1, s2] = outcome
return outcome return outcome
def _sig(st): def _sig(st):

View file

@ -16,6 +16,9 @@ Core and Builtins
Library Library
------- -------
- Issue #11802: The cache in filecmp now has a maximum size of 100 so that
it won't grow without bound.
- Issue #12404: Remove C89 incompatible code from mmap module. Patch by Akira - Issue #12404: Remove C89 incompatible code from mmap module. Patch by Akira
Kitada. Kitada.