Read in large file and make dictionary
问题 I have a large file which I need to read in and make a dictionary from. I would like this to be as fast as possible. However my code in python is too slow. Here is a minimal example that shows the problem. First make some fake data paste <(seq 20000000) <(seq 2 20000001) > largefile.txt Now here is a minimal piece of python code to read it in and make a dictionary. import sys from collections import defaultdict fin = open(sys.argv[1]) dict = defaultdict(list) for line in fin: parts = line