mirror of
https://github.com/python/cpython.git
synced 2025-07-31 23:23:11 +00:00
bpo-43977: Document the new pattern matching type flags (GH-25734)
This commit is contained in:
parent
cbb7b9ed4a
commit
9387fac100
2 changed files with 46 additions and 0 deletions
|
@ -1219,6 +1219,50 @@ and :c:type:`PyType_Type` effectively act as defaults.)
|
||||||
.. versionadded:: 3.10
|
.. versionadded:: 3.10
|
||||||
|
|
||||||
|
|
||||||
|
.. data:: Py_TPFLAGS_MAPPING
|
||||||
|
|
||||||
|
This bit indicates that instances of the class may match mapping patterns
|
||||||
|
when used as the subject of a :keyword:`match` block. It is automatically
|
||||||
|
set when registering or subclassing :class:`collections.abc.Mapping`, and
|
||||||
|
unset when registering :class:`collections.abc.Sequence`.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
:const:`Py_TPFLAGS_MAPPING` and :const:`Py_TPFLAGS_SEQUENCE` are
|
||||||
|
mutually exclusive; it is an error enable both flags simultaneously.
|
||||||
|
|
||||||
|
**Inheritance:**
|
||||||
|
|
||||||
|
This flag is inherited by types that do not already set
|
||||||
|
:const:`Py_TPFLAGS_SEQUENCE`.
|
||||||
|
|
||||||
|
.. seealso:: :pep:`634` -- Structural Pattern Matching: Specification
|
||||||
|
|
||||||
|
.. versionadded:: 3.10
|
||||||
|
|
||||||
|
|
||||||
|
.. data:: Py_TPFLAGS_SEQUENCE
|
||||||
|
|
||||||
|
This bit indicates that instances of the class may match sequence patterns
|
||||||
|
when used as the subject of a :keyword:`match` block. It is automatically
|
||||||
|
set when registering or subclassing :class:`collections.abc.Sequence`, and
|
||||||
|
unset when registering :class:`collections.abc.Mapping`.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
:const:`Py_TPFLAGS_MAPPING` and :const:`Py_TPFLAGS_SEQUENCE` are
|
||||||
|
mutually exclusive; it is an error enable both flags simultaneously.
|
||||||
|
|
||||||
|
**Inheritance:**
|
||||||
|
|
||||||
|
This flag is inherited by types that do not already set
|
||||||
|
:const:`Py_TPFLAGS_MAPPING`.
|
||||||
|
|
||||||
|
.. seealso:: :pep:`634` -- Structural Pattern Matching: Specification
|
||||||
|
|
||||||
|
.. versionadded:: 3.10
|
||||||
|
|
||||||
|
|
||||||
.. c:member:: const char* PyTypeObject.tp_doc
|
.. c:member:: const char* PyTypeObject.tp_doc
|
||||||
|
|
||||||
An optional pointer to a NUL-terminated C string giving the docstring for this
|
An optional pointer to a NUL-terminated C string giving the docstring for this
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Document the new :const:`Py_TPFLAGS_MAPPING` and
|
||||||
|
:const:`Py_TPFLAGS_SEQUENCE` type flags.
|
Loading…
Add table
Add a link
Reference in a new issue