Skip to content

PEP 465

A dedicated infix operator for matrix multiplication (행렬 곱셈 연산자 @)

Abstract

This PEP proposes a new binary operator to be used for matrix multiplication, called @. (Mnemonic: @ is * for mATrices.)

Specification

A new binary operator is added to the Python language, together with the corresponding in-place version:

Op

Precedence/associativity

Methods

@

Same as *

__matmul__, __rmatmul__

@=

n/a

__imatmul__

Example

import torch

a = torch.randn(10000,10000).cuda()
b = torch.randn(10000,10000).cuda()
c = a @ b

See also

Favorite site