Created
June 5, 2014 14:50
-
-
Save yassu/c496766b26ee39a705dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 timeit | |
def get_average(array): | |
return sum(array) / len(array) | |
t = timeit.Timer('cond=True; cond == True') | |
print(get_average(t.repeat(100))) | |
# -> 0.04552456719000474 | |
t = timeit.Timer('cond=True; cond is True') | |
print(get_average(t.repeat(100))) | |
# -> 0.03570362770999054 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment