2 ms·
Well, for mathematics and such cases (physics etc), yes, I agree that x vs self.position.x etc is handier. But I wouldn't ever do it for the "more performant"
by coldtea 11y ago
Well, for mathematics and such cases (physics etc), yes, I agree that x vs self.position.x etc is handier.
But I wouldn't ever do it for the "more performant" part, unless I have profiled the code and it indeed makes a non trivial difference (I know aliasing to a local makes a difference it itself - but I mean it should be significant when the whole program is taken into account, even if it was 1000x faster to access the aliased local, it wouldn't make sense to optimize a part of the program with it, if said part is only responsible for 1% of the total running time).
For the general case, I suggested i, j, k only because they are well known conventions, so their meaning will be instantly understood (and of course, if one can avoid such indexes altogether, e.g. with a "for item in" loop, one should).