def slow_check(hashed, item):
    matches = on_disk.search((hashed,))
for record in matches:
    if item == record.value:
        return True
return False
for large_item in many_items:
    hashed = hash(large_item)
if hashed not in fast_check or not slow_check(hashed, large_item):
    on_disk.append((hashed, large_item))
fast_check.add(hashed)
process(large_item)
тип данных python для отслеживания дубликатов