xxxxxxxxxx
# The "timeit" module lets you measure the execution
# time of small bits of Python code
>>> import timeit
>>> timeit.timeit('"-".join(str(n) for n in range(100))',
number=10000)
0.3412662749997253
>>> timeit.timeit('"-".join([str(n) for n in range(100)])',
number=10000)
0.2996307989997149
>>> timeit.timeit('"-".join(map(str, range(100)))',
number=10000)
0.24581470699922647
xxxxxxxxxx
# The "timeit" module lets you measure the execution time of
# small bits of Python code
import timeit
timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
# Out[3]: 0.14309199999999933
timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000)
# Out[4]: 0.13920909999999864
timeit.timeit('"-".join(map(str, range(100)))', number=10000)
# Out[5]: 0.09380910000000142