Remove Redundant Sequences from FASTA file in Python
Your code (as currently formatted) should generate the correct output, but it is not efficient. Make seen a set to improve these O(n) in calls to O(1) time complexity- this will speed it up a lot
seen = set()
records = []

for record in SeqIO.parse(&quot;b4r2.fasta&quot;, &quot;fasta&quot;):  
    if record.seq not in seen:
        seen.add(record.seq)
        records.append(record)