for outputItem in outputList:
    key = outputItem[4]
if key in details:
    for item in details[key]:
        if len(details[key]) > 1:
            item[30] = '1'
yield item
res = reduceOutputListToPossibleMatches(outputList, detailsList)
with open('somefile', 'w') as f:
    f.writelines(res)
Могут ли списки справиться с миллионом элементов?