Created
February 18, 2015 20:31
-
-
Save mahmoud/c9bedf486562ed4dff98 to your computer and use it in GitHub Desktop.
Timeits!
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
# "in" faster than re search for single character searches | |
# PS also held true for longer strings | |
$ python -m timeit -s 'import re; _re = re.compile("[{]",re.UNICODE); target = "wwoooo{ooo"' '_re.search(target)' | |
10000000 loops, best of 3: 0.159 usec per loop | |
$ python -m timeit -s 'target = "wwoooo{ooo"' '"{" in target' | |
10000000 loops, best of 3: 0.0269 usec per loop | |
##### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment