import timeit from six import u MAX=1000000 identity = lambda x: x def carrot(): return u'The quick brown fox jumped over the lazy dog' def stick(): return identity('The quick brown fox jumped over the lazy dog') def big_bad_stick(): return u('The quick brown fox jumped over the lazy dog') t = timeit.Timer('carrot()', setup='from __main__ import carrot') print(t.repeat(3, MAX)) t = timeit.Timer('stick()', setup='from __main__ import stick') print(t.repeat(3, MAX)) t = timeit.Timer('big_bad_stick()', setup='from __main__ import big_bad_stick') print(t.repeat(3, MAX))