Skip to content

Instantly share code, notes, and snippets.

@artyom
Created July 31, 2017 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artyom/3d6d52e718987d2cefa4a32814eb4d4a to your computer and use it in GitHub Desktop.
Save artyom/3d6d52e718987d2cefa4a32814eb4d4a to your computer and use it in GitHub Desktop.
recheck ¶ cat naive.py
import re
for i in xrange(0,1000000):
re.match("^[\w-]+:\s", "foo: bar")
recheck ¶ time python naive.py
real 0m1.479s
user 0m1.443s
sys 0m0.020s
recheck ¶ cat compiled.py
import re
r = re.compile("^[\w-]+:\s")
for i in xrange(0,1000000):
r.match("foo: bar")
recheck ¶ time python compiled.py
real 0m0.582s
user 0m0.556s
sys 0m0.015s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment