def method():
    with open(input_file, 'r') as inf:
        with open(output_file, 'w') as ouf:
            seen = set()
for line in itertools.islice(inf, None, None, 4):
    pass
Улучшение скорости скрипта python