I used the standard Python module timeit. The class initializer takes two strings of "stmt" or code, and "setup", and has a method of the same name that takes the number of repetitions as an argument.
I tested four approaches:
•
if ... elif ... elif ... elif
• a list comprehension with a dictionary lookup
• sequential string replacement
dna = dna.replace(n1,n2)
• use of the string module method
maketrans
The results for 10,000 reps were as follows: