PEP 614: Remove matmul section and clarify the current restrictions (#1305)
This commit is contained in:
parent
85c431c827
commit
b34adc092e
30
pep-0614.rst
30
pep-0614.rst
|
@ -9,15 +9,16 @@ Type: Standards Track
|
||||||
Content-Type: text/x-rst
|
Content-Type: text/x-rst
|
||||||
Created: 10-Feb-2020
|
Created: 10-Feb-2020
|
||||||
Python-Version: 3.9
|
Python-Version: 3.9
|
||||||
Post-History: 10-Feb-2020
|
Post-History: 11-Feb-2020
|
||||||
Resolution:
|
Resolution:
|
||||||
|
|
||||||
|
|
||||||
Abstract
|
Abstract
|
||||||
========
|
========
|
||||||
|
|
||||||
This PEP proposes allowing functions and classes to be decorated with
|
Python currently requires that all decorators consist of a dotted
|
||||||
any valid expression.
|
name, optionally followed by a single call. This PEP proposes removing
|
||||||
|
these limitations and allowing decorators to be any valid expression.
|
||||||
|
|
||||||
|
|
||||||
Motivation
|
Motivation
|
||||||
|
@ -193,29 +194,6 @@ This new grammar is fully backward-compatible with the existing
|
||||||
grammar.
|
grammar.
|
||||||
|
|
||||||
|
|
||||||
Binary Matrix Multiplication
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
One interesting case is the binary ``@`` operator, which was added to
|
|
||||||
the language after decorators were first introduced. With the proposed
|
|
||||||
change to the grammar, the following decorator expression will be
|
|
||||||
unambiguous legal syntax::
|
|
||||||
|
|
||||||
@a @ b
|
|
||||||
def f():
|
|
||||||
...
|
|
||||||
|
|
||||||
However, this pathological case is unlikely to occur in practice, as
|
|
||||||
there are no known examples of binary matrix multiplication results
|
|
||||||
which may used as decorators. Likely the only people who would do this
|
|
||||||
are those who currently write similarly obfuscated toy code::
|
|
||||||
|
|
||||||
@_(a
|
|
||||||
@b)
|
|
||||||
def f():
|
|
||||||
...
|
|
||||||
|
|
||||||
|
|
||||||
How To Teach This
|
How To Teach This
|
||||||
=================
|
=================
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue