[pypy-dev] pypy1.6 slow on string-heavy ops

Vincent Legoll vincent.legoll at gmail.com
Fri Aug 19 00:24:53 CEST 2011


Hello,

Try this:

import sys

fasta_file = sys.argv[1]  # should be *.fa
print 'loading dna from', fasta_file
chroms = {}
dna = []
for l in open(fasta_file):
    if l.startswith('>'):  # new chromosome
        if len(dna) > 0:
            chroms[chrom] = ''.join(dna)
        chrom = l.strip().replace('>', '')
        dna = []
    else:
        dna.append(l.rstrip())
if len(dna) > 0:
    chroms[chrom] = ''.join(dna)

-- 
Vincent Legoll


More information about the pypy-dev mailing list