stmt = 's[:5] + "a" + s[6:]'
setup = 's = "b" * {0}'
times = [timeit.timeit(stmt=stmt, setup=setup.format(i), number=10) for i in
    range(100000)]
sum(times) * 1.0 / len(times)
times[-1]
How are basic data types (strings and integers) implemented in Python and Perl