Created
March 29, 2019 18:18
-
-
Save juanarrivillaga/c3bf1e727c146deb1af0357791189398 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# note, using the %%timeit ipython magic, the expression on the first line is not included in the time testing | |
In [3]: %%timeit items = list(map(str, range(1))) | |
...: 'foo' in items | |
...: | |
...: | |
33 ns ± 1.79 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) | |
In [4]: %%timeit items = set(map(str, range(1))) | |
...: 'foo' in items | |
...: | |
...: | |
25.5 ns ± 0.395 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) | |
In [5]: %%timeit items = list(map(str, range(100))) | |
...: 'foo' in items | |
...: | |
...: | |
993 ns ± 9 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each) | |
In [6]: %%timeit items = set(map(str, range(100))) | |
...: 'foo' in items | |
...: | |
...: | |
26.2 ns ± 0.645 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) | |
In [7]: %%timeit items = list(map(str, range(1000))) | |
...: 'foo' in items | |
...: | |
...: | |
12.6 µs ± 77.9 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each) | |
In [8]: %%timeit items = set(map(str, range(1000))) | |
...: 'foo' in items | |
...: | |
...: | |
29.3 ns ± 0.47 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment