From e0508032349d7c29ecb49554b1b9255edf784831 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sun, 18 May 2014 20:31:07 -0700 Subject: [PATCH] Use a deque to avoid keeping all the scanned files alive Avoid keeping all the files that have been read and scanned in memory by use a deque and popping files off after they have been read (this allows the gc to clean them up). --- doc8/main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc8/main.py b/doc8/main.py index d39d1de..988a035 100644 --- a/doc8/main.py +++ b/doc8/main.py @@ -31,6 +31,7 @@ What is checked: """ import argparse +import collections import os from six.moves import configparser @@ -140,13 +141,14 @@ def main(): args['ignore'].update(cfg.pop("ignore", set())) args.update(cfg) - files = [] + files = collections.deque() for filename in utils.find_files(args.pop('paths', []), FILE_PATTERNS): files.append(file_parser.parse(filename)) ignoreables = frozenset(args.pop('ignore', [])) errors = 0 - for f in files: + while files: + f = files.popleft() for c in fetch_checks(args): try: reports = set(c.REPORTS)