input = open('input.txt')
x = (process_line(line) for line in input)
y = p.imap(process_item, x)
z = (generate_output_line(item) + '\n' for item in y)
output = open('output.txt', 'w')
output.writelines(z)
How can I parallelize a pipeline of generators/iterators in Python?