Hi,

I cannot confirm this. At least not as an absolute. As [1] shows, it basically depends on the *mood* of Python's virtual machine which one is faster.

Some attempt at an explanation: While the square root was an actual hinderance for CG in the early days and led to things like the infamous fast inverse square root hack, modern chipsets have specialised instructions for the square root which more or less completely nullify the problem (it's still slower than doing nothing of course). So the computer science aversion against calculating the square root is actually more of a cultivated habit than an actual problem these days.

So the actual difference between taking the square root and not taking it, is quite small these days, because of modern chipset instructions and modern compilers making use of them. And that difference can not only be drowned but also inverted by the relative randomness of timings in the tenth or hundreds of nanoseconds range by code that runs on a virtual machine.

Cheers,

zipit

[1]

```
import c4d
import random
import time
def timeit(data, function):
"""A poors mans function timing on a collection of objects.
"""
timing = 0
for item in data:
t0 = time.time()
getattr(item, function)()
timing += time.time() - t0
return timing * (1./len(data))
def main():
"""Entry point.
"""
# 1 million psuedo random vectors.
count = int(1E6)
vectors = tuple(c4d.Vector(random.uniform(-1, 1),
random.uniform(-1, 1),
random.uniform(-1, 1)) for _ in range(count))
# Ten rounds of calculating the length and the squared length for them.
for i in range(10):
msg = "Round: {}, Function: {}, Time (sec): {}"
for f in ("GetLength", "GetLengthSquared"):
print msg.format(i, f, timeit(vectors, f))
if __name__ == "__main__":
main()
```

```
Round: 0, Function: GetLength, Time (sec): 2.47002124786e-07
Round: 0, Function: GetLengthSquared, Time (sec): 2.60000228882e-07
Round: 1, Function: GetLength, Time (sec): 2.35999584198e-07
Round: 1, Function: GetLengthSquared, Time (sec): 2.6100063324e-07
Round: 2, Function: GetLength, Time (sec): 3.4800028801e-07
Round: 2, Function: GetLengthSquared, Time (sec): 2.62000322342e-07
Round: 3, Function: GetLength, Time (sec): 2.61000871658e-07
Round: 3, Function: GetLengthSquared, Time (sec): 2.63000011444e-07
Round: 4, Function: GetLength, Time (sec): 2.63998985291e-07
Round: 4, Function: GetLengthSquared, Time (sec): 2.51001596451e-07
Round: 5, Function: GetLength, Time (sec): 2.68000841141e-07
Round: 5, Function: GetLengthSquared, Time (sec): 2.65999794006e-07
Round: 6, Function: GetLength, Time (sec): 2.46999025345e-07
Round: 6, Function: GetLengthSquared, Time (sec): 2.59999036789e-07
Round: 7, Function: GetLength, Time (sec): 2.48000144958e-07
Round: 7, Function: GetLengthSquared, Time (sec): 2.37002134323e-07
Round: 8, Function: GetLength, Time (sec): 2.5899887085e-07
Round: 8, Function: GetLengthSquared, Time (sec): 2.67003059387e-07
Round: 9, Function: GetLength, Time (sec): 2.48999834061e-07
Round: 9, Function: GetLengthSquared, Time (sec): 2.57003307343e-07
>>>
```