Created
August 27, 2017 10:13
-
-
Save manuel-delverme/8d53afe46b222ac913b023e5155df650 to your computer and use it in GitHub Desktop.
transpose vs T vs reshape
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 | |
setup = 'import numpy as np; a=np.random.randn(10)' | |
reshape = timeit.Timer('a.reshape(-1, 10)', setup=setup) | |
transp = timeit.Timer('a.transpose()', setup=setup) | |
T = timeit.Timer('a.T', setup=setup) | |
print("reshape", reshape.timeit(number=int(1e6))) | |
print("transp", transp.timeit(number=int(1e6))) | |
print("T", T.timeit(number=int(1e6))) | |
print("reshape", reshape.timeit(number=int(1e6))) | |
print("transp", transp.timeit(number=int(1e6))) | |
print("T", T.timeit(number=int(1e6))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment