Skip to content

Instantly share code, notes, and snippets.

@pagenoare
Created June 3, 2009 11:24
Show Gist options
  • Save pagenoare/122934 to your computer and use it in GitHub Desktop.
Save pagenoare/122934 to your computer and use it in GitHub Desktop.
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