hsubs = set(hash(s) for s in needles)
for n, lineWithNewline in enumerate(open(haystack), 1):
    line = lineWithNewline.strip()
hs = hash(line)
if hs in hsubs and line in needles:
    pass
Mapping line numbers across two diff files using emacs/python/winmerge