+ 4
Which approach is faster in python?
Suppose that there are 3 ways to solve a problen. How do I know that my code is the fastest for the task Is there a site or a program to rate the code?
4 Antworten
+ 4
onur rr
Know your algorithm complexity.
The more complex an algorithm is the slower it gets, that applies for ALL languages.
e.g.
A double for loop has complexity of O(n^2). (its very slow)
A single for loop has complexity of O(n).
(ok speed but not great either)
More info on algorithm complexity:
http://bigocheatsheet.com
https://discrete.gr/complexity/
https://www.sololearn.com/learn/6362/?ref=app
0
Thanks for all the answers. I see time.time and time.clock as answers. Is there a difference between them ?
0
It depends on your algorithm