mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Include length in stats for UNPACK_SEQUENCE. (GH-31254)
This commit is contained in:
parent
1d6ce67c29
commit
15ee55528e
2 changed files with 30 additions and 8 deletions
|
@ -2740,10 +2740,10 @@ handle_eval_breaker:
|
||||||
PREDICTED(UNPACK_SEQUENCE);
|
PREDICTED(UNPACK_SEQUENCE);
|
||||||
PyObject *seq = POP(), *item, **items;
|
PyObject *seq = POP(), *item, **items;
|
||||||
#ifdef Py_STATS
|
#ifdef Py_STATS
|
||||||
extern int _PySpecialization_ClassifySequence(PyObject *);
|
extern int _PySpecialization_ClassifySequence(PyObject *, int);
|
||||||
_py_stats.opcode_stats[UNPACK_SEQUENCE].specialization.failure++;
|
_py_stats.opcode_stats[UNPACK_SEQUENCE].specialization.failure++;
|
||||||
_py_stats.opcode_stats[UNPACK_SEQUENCE].specialization.
|
_py_stats.opcode_stats[UNPACK_SEQUENCE].specialization.
|
||||||
failure_kinds[_PySpecialization_ClassifySequence(seq)]++;
|
failure_kinds[_PySpecialization_ClassifySequence(seq, oparg)]++;
|
||||||
#endif
|
#endif
|
||||||
if (PyTuple_CheckExact(seq) &&
|
if (PyTuple_CheckExact(seq) &&
|
||||||
PyTuple_GET_SIZE(seq) == oparg) {
|
PyTuple_GET_SIZE(seq) == oparg) {
|
||||||
|
|
|
@ -602,8 +602,26 @@ initial_counter_value(void) {
|
||||||
#define SPEC_FAIL_FOR_ITER_ENUMERATE 23
|
#define SPEC_FAIL_FOR_ITER_ENUMERATE 23
|
||||||
|
|
||||||
/* UNPACK_SEQUENCE */
|
/* UNPACK_SEQUENCE */
|
||||||
#define SPEC_FAIL_UNPACK_SEQUENCE_TUPLE 10
|
#define SPEC_FAIL_UNPACK_SEQUENCE_TUPLE_0 9
|
||||||
#define SPEC_FAIL_UNPACK_SEQUENCE_LIST 11
|
#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
|
static int
|
||||||
|
@ -1978,15 +1996,19 @@ int
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_PySpecialization_ClassifySequence(PyObject *seq)
|
_PySpecialization_ClassifySequence(PyObject *seq, int n)
|
||||||
{
|
{
|
||||||
|
assert(n >= 0);
|
||||||
|
if (n > 4) {
|
||||||
|
n = 5;
|
||||||
|
}
|
||||||
if (PyTuple_CheckExact(seq)) {
|
if (PyTuple_CheckExact(seq)) {
|
||||||
return SPEC_FAIL_UNPACK_SEQUENCE_TUPLE;
|
return SPEC_FAIL_UNPACK_SEQUENCE_TUPLE_0 + n;
|
||||||
}
|
}
|
||||||
if (PyList_CheckExact(seq)) {
|
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
|
int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue