Re:How copying an int made my code 11 times faster
by Cyphase on Monday February 20, 2017 @03:20AM
(#13685433)
I tried this on my machine, then tried a pure Python version; I only changed three lines, to:
Here are my times:
As you can see, the pure Python version is faster than the Numpy version, and also has a larger margin between unsorted and sorted. PyPy is of course faster than both, and also has an even greater margin between unsorted and sorted (2.63x faster).
[ Parent
| on HN ]
Re:How copying an int made my code 11 times faster
by MooMooMilkParty on Monday February 20, 2017 @05:12AM
(#13686048)
Good call on going pure python. To take this a bit further I made your changes and used numba with @jit(nopython=True, cache=True), for some interesting results. If I do include the sorting into the timing:
Unsorted execution time: 0.2175428867340088 seconds
Sorted execution time: 1.133354663848877 seconds
And if I don't: Unsorted execution time: 0.21171283721923828 seconds
Sorted execution time: 0.08376479148864746 seconds