Created
March 26, 2015 09:53
-
-
Save deronnax/984499ee7ef62b9b81f4 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
import re | |
import time | |
reg = re.compile(r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]') | |
with open('requests/__init__.py', 'r') as fd: | |
t1 = time.time() | |
version = reg.search(fd.read()).group() | |
t2 = time.time() | |
print version | |
print 'mine:', (t2 - t1) * 1000 | |
with open('requests/__init__.py', 'r') as fd: | |
t1 = time.time() | |
for line in fd: | |
m = reg.match(line) | |
if m: | |
version = m.group(1) | |
break | |
t2 = time.time() | |
print version | |
print 'his', (t2 - t1) * 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment