diff options
author | Mark Shannon <mark@hotpy.org> | 2021-04-30 08:50:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-30 08:50:28 (GMT) |
commit | 069e81ab3da46c441335ca762c4333b7bd91861d (patch) | |
tree | 02716907f4513a812cf2c72309cc4e6f133b3ab3 /Include | |
parent | 2abbd8f2add5e80b86a965625b9a77ae94a101cd (diff) | |
download | cpython-069e81ab3da46c441335ca762c4333b7bd91861d.zip cpython-069e81ab3da46c441335ca762c4333b7bd91861d.tar.gz cpython-069e81ab3da46c441335ca762c4333b7bd91861d.tar.bz2 |
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.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pycore_interp.h | 4 | ||||
-rw-r--r-- | Include/object.h | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h index 11d31da..bfd082b 100644 --- a/Include/internal/pycore_interp.h +++ b/Include/internal/pycore_interp.h @@ -247,10 +247,6 @@ struct _is { // importlib module PyObject *importlib; - // Kept handy for pattern matching: - PyObject *map_abc; // _collections_abc.Mapping - PyObject *seq_abc; // _collections_abc.Sequence - /* Used in Modules/_threadmodule.c. */ long num_threads; /* Support for runtime thread stack size tuning. diff --git a/Include/object.h b/Include/object.h index d8476f9..cffe72c 100644 --- a/Include/object.h +++ b/Include/object.h @@ -320,6 +320,13 @@ Code can use PyType_HasFeature(type_ob, flag_value) to test whether the given type object has a specified feature. */ +#ifndef Py_LIMITED_API +/* Set if instances of the type object are treated as sequences for pattern matching */ +#define Py_TPFLAGS_SEQUENCE (1 << 5) +/* Set if instances of the type object are treated as mappings for pattern matching */ +#define Py_TPFLAGS_MAPPING (1 << 6) +#endif + /* Set if the type object is immutable: type attributes cannot be set nor deleted */ #define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8) |