def linematcher(haystack, needles, lineNumbers):
    f = open(needles)
needles = [line.strip() for n, line in enumerate(f, 1) if n in lineNumbers]
f.close()
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
Сопоставление номеров строк в двух файлах различий с использованием emacs/python/winmerge