timeit Timer import random string str random random for in xrange 10 s

1
2
3
4
5
>>> z = timeit.Timer("a+b+c+d+e+f+g+h+i+k", "import random; string=[str(random.random()) for x in xrange(10)];a, b, c, d, e, f, g, h, i, k = string")
>>> z.timeit()
>>> x = timeit.Timer("''.join(string)", "import random; string=[str(random.random()) for x in xrange(10)]")
>>> x.timeit()