Skip to content

Instantly share code, notes, and snippets.

@wardi
Created December 4, 2014 18:30
Embed
What would you like to do?
>>> 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