Looks like using slice is 4x faster. Timed with %timeit command of YPython.
%timeit
YPython
%timeit s[::-1] 81 ns ± 1.05 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) %timeit "".join(reversed(s)) 311 ns ± 2.89 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
just find out your comment, good to know how to count program time, thx
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Looks like using slice is 4x faster. Timed with
%timeit
command ofYPython
.just find out your comment, good to know how to count program time, thx