diff options
author | Mark Shannon <mark@hotpy.org> | 2022-02-14 10:01:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-14 10:01:31 (GMT) |
commit | 15ee55528e1cbc47ef7e9f64186393eee40a49d9 (patch) | |
tree | cd1522b304dc4a33fe403b364775a2d16875440c /Python/specialize.c | |
parent | 1d6ce67c29aa2166ef326952cb605b908fb4f987 (diff) | |
download | cpython-15ee55528e1cbc47ef7e9f64186393eee40a49d9.zip cpython-15ee55528e1cbc47ef7e9f64186393eee40a49d9.tar.gz cpython-15ee55528e1cbc47ef7e9f64186393eee40a49d9.tar.bz2 |
Include length in stats for UNPACK_SEQUENCE. (GH-31254)
Diffstat (limited to 'Python/specialize.c')
-rw-r--r-- | Python/specialize.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/Python/specialize.c b/Python/specialize.c index 1259a3c..b54a2ec 100644 --- a/Python/specialize.c +++ b/Python/specialize.c @@ -602,8 +602,26 @@ initial_counter_value(void) { #define SPEC_FAIL_FOR_ITER_ENUMERATE 23 /* UNPACK_SEQUENCE */ -#define SPEC_FAIL_UNPACK_SEQUENCE_TUPLE 10 -#define SPEC_FAIL_UNPACK_SEQUENCE_LIST 11 +#define SPEC_FAIL_UNPACK_SEQUENCE_TUPLE_0 9 +#define SPEC_FAIL_UNPACK_SEQUENCE_TUPLE_1 10 +#define SPEC_FAIL_UNPACK_SEQUENCE_TUPLE_2 11 +#define SPEC_FAIL_UNPACK_SEQUENCE_TUPLE_3 12 +#define SPEC_FAIL_UNPACK_SEQUENCE_TUPLE_4 13 +#define SPEC_FAIL_UNPACK_SEQUENCE_TUPLE_N 14 + +#define SPEC_FAIL_UNPACK_SEQUENCE_LIST_0 15 +#define SPEC_FAIL_UNPACK_SEQUENCE_LIST_1 16 +#define SPEC_FAIL_UNPACK_SEQUENCE_LIST_2 17 +#define SPEC_FAIL_UNPACK_SEQUENCE_LIST_3 18 +#define SPEC_FAIL_UNPACK_SEQUENCE_LIST_4 19 +#define SPEC_FAIL_UNPACK_SEQUENCE_LIST_N 20 + +#define SPEC_FAIL_UNPACK_SEQUENCE_OTHER_0 21 +#define SPEC_FAIL_UNPACK_SEQUENCE_OTHER_1 22 +#define SPEC_FAIL_UNPACK_SEQUENCE_OTHER_2 23 +#define SPEC_FAIL_UNPACK_SEQUENCE_OTHER_3 24 +#define SPEC_FAIL_UNPACK_SEQUENCE_OTHER_4 25 +#define SPEC_FAIL_UNPACK_SEQUENCE_OTHER_N 26 static int @@ -1978,15 +1996,19 @@ int } int -_PySpecialization_ClassifySequence(PyObject *seq) +_PySpecialization_ClassifySequence(PyObject *seq, int n) { + assert(n >= 0); + if (n > 4) { + n = 5; + } if (PyTuple_CheckExact(seq)) { - return SPEC_FAIL_UNPACK_SEQUENCE_TUPLE; + return SPEC_FAIL_UNPACK_SEQUENCE_TUPLE_0 + n; } if (PyList_CheckExact(seq)) { - return SPEC_FAIL_UNPACK_SEQUENCE_LIST; + return SPEC_FAIL_UNPACK_SEQUENCE_LIST_0 + n; } - return SPEC_FAIL_OTHER; + return SPEC_FAIL_UNPACK_SEQUENCE_OTHER_0 + n; } int |