Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Wow, thanks! That explains it.
The problem is rather that the way the perfs are measured is biased ("like usual"...?)
Considering the inputs used, the VERY GREAT MAJORITY of the outputs are -1. That means that what is measured is actually:
So, yeah, v2 is ofc a tiny bit slower.
Now, if you try with a perfect square as input for each call, the result will be the opposite:
Wow, this brings me back :-)
Checked the code, the difference is still present, and the first option is faster.
I'm not sure why exactly, checked the opcodes using
dis.dis
, and figured that the only difference is thatis called for the first one, and
for the second function (same opcodes omitted).
So it looks like storing a value is more expensive then calling a function.
I know that this is old, but why is it slower? Does the assignment really add more time than recalculating the sqrt?
This comment is hidden because it contains spoiler information about the solution
This calulates
sqrt(sq)
twice. Is it more efficient to lets = sqrt(sq)
and then uses
?