CKTIS / Python
Operator @=
Assigns the result of matrix multiplication back to its target.
Version: Python 3.14; repository image, production runtime not attested
Syntax
left @= rightAssigns the result of matrix multiplication back to its target.
Use augmented matrix multiplication when replacing the target by a product. A class implementing the in-place method can update its storage or return a different result object.
This example defines only the ordinary product. The old row survives through the alias, while the variable holding the result becomes an integer; matrix shape and result type are determined by the implementing class.
If the class supplies no in-place method, ordinary matrix multiplication can rebind the target to a different type while aliases keep the old object.
Syntax
left @= right
__imatmul__, __matmul__, __rmatmul__ · TypeError
Worked example
row = Row((2, 5)); old = row; row @= (3, 4)
row → 26
tuple(old) → (2, 5)
Examples
class Row(tuple):
def __matmul__(self, column):
return sum(x * y for x, y in zip(self, column, strict=True))
row = Row((2, 5))
column = (3, 4)
alias = row
row @= column
print(row)
print(tuple(alias))
Result
26 (2, 5)
If the class supplies no in-place method, ordinary matrix multiplication can rebind the target to a different type while aliases keep the old object.