|
|
|
|
|
by kragen
1815 days ago
|
|
It's not shockingly bad to call len(arr) each time through the loop. It would be if we were talking about something like strlen() in C, but in Python it's just one more constant-time† operation each time through the loop, and not a very expensive one at that. Caching it in a local variable would still be better. ______ † Nothing is really constant-time in CPython, but it's pretty close. |
|