Created
March 9, 2011 22:53
-
-
Save mattjmorrison/863187 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
def one_third(x): | |
return x / 3.0 | |
def make_table(pairs): | |
'Unoptimized Example' | |
result = [] | |
for value in pairs: | |
x = one_third(value) | |
result.append(format(value, '9.5f')) | |
return '\n'.join(result) | |
def make_table2(pairs): | |
'Optimized version' | |
result = [] | |
result_append = result.append # bound method | |
_format = format # localized | |
for value in pairs: | |
x = value / 3.0 # in-lined | |
result_append(_format(value, '9.5f')) | |
return '\n'.join(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment