Skip to content
Search

PEP 465

lastmod 2025-12-05created 2025-12-051 edits

A dedicated infix operator for matrix multiplication (matrix multiplication operator @)

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

author Zer0 sitemap