Collect stats for UNPACK_SEQUENCE. (GH-31105)

This commit is contained in:
Mark Shannon 2022-02-03 18:40:56 +00:00 committed by GitHub
parent da4d4ec185
commit a0401d8372
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View file

@ -572,6 +572,10 @@ initial_counter_value(void) {
#define SPEC_FAIL_ITER_DICT_VALUES 22
#define SPEC_FAIL_ITER_ENUMERATE 23
/* UNPACK_SEQUENCE */
#define SPEC_FAIL_TUPLE 10
#define SPEC_FAIL_LIST 11
static int
specialize_module_load_attr(
@ -1880,7 +1884,6 @@ _Py_Specialize_CompareOp(PyObject *lhs, PyObject *rhs,
adaptive->counter = initial_counter_value();
}
int
_PySpecialization_ClassifyIterator(PyObject *iter)
{
@ -1930,3 +1933,15 @@ int
}
return SPEC_FAIL_OTHER;
}
int
_PySpecialization_ClassifySequence(PyObject *seq)
{
if (PyTuple_CheckExact(seq)) {
return SPEC_FAIL_TUPLE;
}
if (PyList_CheckExact(seq)) {
return SPEC_FAIL_LIST;
}
return SPEC_FAIL_OTHER;
}