Skip to content

Instantly share code, notes, and snippets.

@wardi
Created December 4, 2014 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wardi/a22b65aeee409283c0b9 to your computer and use it in GitHub Desktop.
Save wardi/a22b65aeee409283c0b9 to your computer and use it in GitHub Desktop.
>>> timeit.timeit("np.array([42]*10000, dtype=float)", "import numpy as np", number=15000)
14.971487045288086
>>> timeit.timeit("np.ones(10000, dtype=float) * 42", "import numpy as np", number=15000)
0.5964510440826416
>>> timeit.timeit("np.multiply(np.ones(10000, dtype=float), 42)", "import numpy as np", number=15000)
0.5582938194274902
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment