Comment

Comment by santiagobasulto

I don't doubt Nim, looks like a great language. But that is just an awful Python implementation. I'd do it in this way:

    lines = (line for line in lines("orthocoronavirinae.fasta") if not line.startswith(">"))
    gc_lines = (1 if ('G' in line or 'C' in line) else 0 for line in lines)
    gc = sum(gc_lines)

    total = len(list(gc_lines))

    # Alternatively, a more "memory efficient" total would be:
    total = sum(1 for _ in lines)
Edit: my code is not perfect (I’m typing from my phone, I’m surprised I could even match parentheses).

My point is: this is a highly I/O bound program. The implementation matters. With the correct implementation there shouldn’t be much difference between the languages.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton