mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
bpo-43977: Use tp_flags for collection matching (GH-25723)
* Add Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING, add to all relevant standard builtin classes. * Set relevant flags on collections.abc.Sequence and Mapping. * Use flags in MATCH_SEQUENCE and MATCH_MAPPING opcodes. * Inherit Py_TPFLAGS_SEQUENCE and Py_TPFLAGS_MAPPING. * Add NEWS * Remove interpreter-state map_abc and seq_abc fields.
This commit is contained in:
parent
2abbd8f2ad
commit
069e81ab3d
16 changed files with 74 additions and 83 deletions
|
@ -5717,10 +5717,15 @@ inherit_special(PyTypeObject *type, PyTypeObject *base)
|
|||
else if (PyType_IsSubtype(base, &PyDict_Type)) {
|
||||
type->tp_flags |= Py_TPFLAGS_DICT_SUBCLASS;
|
||||
}
|
||||
|
||||
if (PyType_HasFeature(base, _Py_TPFLAGS_MATCH_SELF)) {
|
||||
type->tp_flags |= _Py_TPFLAGS_MATCH_SELF;
|
||||
}
|
||||
if (PyType_HasFeature(base, Py_TPFLAGS_SEQUENCE)) {
|
||||
type->tp_flags |= Py_TPFLAGS_SEQUENCE;
|
||||
}
|
||||
if (PyType_HasFeature(base, Py_TPFLAGS_MAPPING)) {
|
||||
type->tp_flags |= Py_TPFLAGS_MAPPING;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue