I asked a related but very general question earlier (see especially this response).
This question is very specific. This is all the code I care about:
result = {}
for line in open('input.txt'):
key, value = parse(line)
result[key] = value
The function parse
is completely self-contained (i.e., doesn't use any shared resources).
I have Intel i7-920 CPU (4 cores, 8 threads; I think the threads are more relevant, but I'm not sure).
What can I do to make my program use all the parallel capabilities of this CPU?
I assume I can open this file for reading in 8 different threads without much performance penalty since disk access time is small relative to the total time.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…