|
|
|
|
|
by cf499
1815 days ago
|
|
> That’s actually roughly len(arr) times, not three, since two of the calls are inside the loop. You're right! I noticed it a few minutes ago and changed the wording accordingly. Thanks for pointing out how shockingly bad that algorithm actually is! :D > (...) the reverse function mutates its argument and returns it. Yeah, that mutate + return is confusing. It's also worth noting that, as a result of the mutation, the function doesn't work on immutable types like strings and tuples. |
|
______
† Nothing is really constant-time in CPython, but it's pretty close.