[Python-checkins] cpython (3.2): Issue 11802: filecmp cache was growing without bound.
raymond.hettinger
python-checkins at python.org
Sat Jun 25 17:21:28 CEST 2011
http://hg.python.org/cpython/rev/2bacaf6a80c4
changeset: 70977:2bacaf6a80c4
branch: 3.2
parent: 70974:79f9698777b7
user: Raymond Hettinger <python at rcn.com>
date: Sat Jun 25 17:20:21 2011 +0200
summary:
Issue 11802: filecmp cache was growing without bound.
files:
Lib/filecmp.py | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/Lib/filecmp.py b/Lib/filecmp.py
--- a/Lib/filecmp.py
+++ b/Lib/filecmp.py
@@ -48,11 +48,12 @@
if s1[1] != s2[1]:
return False
- result = _cache.get((f1, f2))
- if result and (s1, s2) == result[:2]:
- return result[2]
- outcome = _do_cmp(f1, f2)
- _cache[f1, f2] = s1, s2, outcome
+ outcome = _cache.get((f1, f2, s1, s2))
+ if outcome is None:
+ outcome = _do_cmp(f1, f2)
+ if len(_cache) > 100: # limit the maximum size of the cache
+ _cache.clear()
+ _cache[f1, f2, s1, s2] = outcome
return outcome
def _sig(st):
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list