Best way to compute length of arbitrary dimension vector?
Gabriel
snoopy.67.z at googlemail.com
Fri Jun 3 17:53:18 EDT 2011
> The dimension is arbitrary, though, so:
>
> length = reduce(math.hypot, self._coords, 0)
>
Thanks, I was going to ask Algis that same question.
But still, is this solution really faster or better than the one using
list comprehension and the expression 'x*x'?
It seems to me that the above solution (using hypot) involves repeated
square roots (with subsequent squaring).
Best regards,
Gabriel.
More information about the Python-list
mailing list