Created
October 11, 2023 00:26
-
-
Save dublado/e8c67ba60c75c82726581c9a304f1fa6 to your computer and use it in GitHub Desktop.
timeit module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment