Skip to content

Instantly share code, notes, and snippets.

@twexler
Last active August 29, 2015 14:02
Show Gist options
  • Save twexler/7e0712828a51bbbcec99 to your computer and use it in GitHub Desktop.
Save twexler/7e0712828a51bbbcec99 to your computer and use it in GitHub Desktop.
[18:47:57] twexler:~ $ python
Python 2.7.6 (default, May 17 2014, 00:21:47)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.29.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import timeit
>>> timeit.timeit('import re;s="perceptes is gay";r=".*gay$";rr = re.compile(r);rr.match(s)')
2.5647430419921875
>>> timeit.timeit('import re;s="perceptes is gay";r=".*gay$";re.match(r, s)')
2.603404998779297
>>>
[18:47:20] twexler:~ $ pypy
Python 2.7.3 (480845e6b1dd, Jul 31 2013, 10:58:28)
[PyPy 2.1.0 with GCC 4.2.1 Compatible Clang Compiler] on darwin
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``PyPy is a tool to keep otherwise
dangerous minds safely occupied.''
>>>> import timeit
>>>> timeit.timeit('import re;s="perceptes is gay";r=".*gay$";re.match(r, s)')
0.22844791412353516
>>>> timeit.timeit('import re;s="perceptes is gay";r=".*gay$";rr = re.compile(r);rr.match(s)')
0.23493003845214844
>>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment