Created
June 3, 2009 11:24
-
-
Save pagenoare/122934 to your computer and use it in GitHub Desktop.
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 [15]: import re | |
In [16]: pattern = re.compile('\(.*\)') | |
In [17]: %timeit pattern.search(string) | |
1000000 loops, best of 3: 1.04 µs per loop | |
In [18]: %timeit '(' in string and ')' in string | |
1000000 loops, best of 3: 260 ns per loop | |
In [19]: s = string | |
In [26]: %timeit s.find('(') < s.find(')') > -1 | |
1000000 loops, best of 3: 1.15 µs per loop | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment