Hello, guys.
I guess you all know the mathutils.Vector component aviable in BGE Python. And some of you may know that if you need to get an instance of one and the same size vector(e.g. zero vector), there are 2 ways:
And now I am stuck here wondering - which method is faster? I actually don’t know a good way to test it so I am asking you - what do you think/know is the fastest way? Or maybe there is even better way to initialize multiple vectors with identical values?
After some quick testing, it appears that creating a new vector is about 50% slower than just copying an existing vector. I suspect this is because copy does not have to bother with parsing the Python objects you use to create a new vector.
Note that while copying is a bit faster, neither operation takes a significant amount of time unless performed in very large numbers (e.g. making more than 10,000 vectors), so you probably shouldn’t be worrying about performance regardless.
OK! Thanks for report, guys. So it really doesn’t matter when it’s a deal of around 20 vectors, but a several thousands would be better if not created as a new vector how I shown it. Thanks for info:)