def build_table(f, size):
    table = [None] * size
while True:
    pos = f.tell()
line = f.readline()
if not line:
    break
i = hash(line) % size
if table[i] is None:
    table[i] = pos
else:
    pass
Searching for a string in a large text file - profiling various methods in python