def search(string, table, f):
    i = hash(string) % len(table)
entry = table[i]
while entry is not None:
    pos = entry.pos if isinstance(entry, Node) else entry
f.seek(pos)
if f.readline() == string:
    return True
entry = entry.__next__ if isinstance(entry, Node) else None
return False
SIZE = 2 ** 24
with open('data.txt', 'r') as f:
    table = build_table(f, SIZE)
print(search('Some test string\n', table, f))
Searching for a string in a large text file - profiling various methods in python