Created
November 4, 2015 12:32
-
-
Save shnjp/b6b14a7c03cb7ff49087 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 | |
print 'pure sum', timeit.timeit('sum([1] * 10000)', number=100) | |
print 'numpy sum', timeit.timeit('numpy.sum([1] * 10000)', 'import numpy', number=100) | |
print 'pure sum', timeit.timeit('sum(x)', setup='x = [1] * 10000', number=100) | |
print 'numpy sum 1', timeit.timeit('numpy.sum(y)', 'import numpy; y = [1] * 10000', number=100) | |
print 'numpy sum 2', timeit.timeit('numpy.sum(z)', 'import numpy; z = numpy.array([1] * 10000)', number=100) | |
print 'numpy sum 3', timeit.timeit('numpy.sum(numpy.array(y))', 'import numpy; y = [1] * 10000', number=100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
result