pattern = re.compile('GET /index\\(.*\\).html')
matches = (pattern.search(line) for line in file(FILE, 'rb') if 'GET' in line)
mapp = (match.group(1) for match in matches if match)
count = defaultdict(int)
Lazyily filtering a file before reading