I think, this is one of the most basic programming questions. And I have a seen a number of different answers for different languages. So I suppose this is language-specific, because unused variables should be treated differently...
Imagine I have a function that is called really a lot. Tens of times on each player's action.
For example it takes an array of KinematicBody2D elements, asks each one its position, and finds the geometrical center (average position.x, average position.y).
Now. For GDScript. Would it be wise to declare temporary variables inside the function every time it is called?
Or maybe it would be better to create few variables inside class and re-use them all the time from inside function?
I mean, if I declare local variables again and again so often, won't this affect performance? The engine would have to allocate memory all the time and then clear it, removing single-use variables again and again.
Sorry if this sounds not very clever.