Python offers in-place operators (+=, *=, /=, @= etc.) to improve memory efficieny when altering a variable. However, the variable you are modifying is always on the 'left' side of the operator: a /= b amounts to a = a*b, not a = b*a. In this example, this does not matter, as multiplication is commutative. However, for non-commutative operations like subtraction, division and (for me specifically) matrix multiplication, how can one invert this order? Something like:
a -= b # -> a = a-b
a =- b # -> a = b-a
In most cases I would not bother using inline operations, but I am simulating rigid bodies and have to perform a lot of matrix operations as efficiently as possible.
To evaluate the effects and options, you could use something like the following:
Output:
The main differences are store/load operations of (temporary) variables. In terms of runtime, these should take less time than the actual computations.