Skip to content

Commit ebd800a

Browse files
committed
add stats
1 parent 0cd4bef commit ebd800a

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

Include/cpython/pystats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#define PYSTATS_MAX_UOP_ID 512
3333

34-
#define SPECIALIZATION_FAILURE_KINDS 37
34+
#define SPECIALIZATION_FAILURE_KINDS 44
3535

3636
/* Stats for determining who is calling PyEval_EvalFrame */
3737
#define EVAL_CALL_TOTAL 0

Python/specialize.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,13 @@ _PyCode_Quicken(_Py_CODEUNIT *instructions, Py_ssize_t size, int enable_counters
597597
#define SPEC_FAIL_BINARY_OP_SUBSCR_TUPLE_SLICE 35
598598
#define SPEC_FAIL_BINARY_OP_SUBSCR_STRING_SLICE 36
599599
#define SPEC_FAIL_BINARY_OP_SUBSCR_NOT_HEAP_TYPE 37
600+
#define SPEC_FAIL_BINARY_OP_SUBSCR_OTHER_SLICE 38
601+
#define SPEC_FAIL_BINARY_OP_SUBSCR_MAPPINGPROXY 39
602+
#define SPEC_FAIL_BINARY_OP_SUBSCR_RE_MATCH 40
603+
#define SPEC_FAIL_BINARY_OP_SUBSCR_ARRAY 41
604+
#define SPEC_FAIL_BINARY_OP_SUBSCR_DEQUE 42
605+
#define SPEC_FAIL_BINARY_OP_SUBSCR_ENUMDICT 43
606+
#define SPEC_FAIL_BINARY_OP_SUBSCR_STACKSUMMARY 44
600607

601608
/* Calls */
602609

@@ -2358,6 +2365,34 @@ binary_op_fail_kind(int oparg, PyObject *lhs, PyObject *rhs)
23582365
}
23592366
}
23602367
Py_XDECREF(descriptor);
2368+
2369+
if (PyObject_TypeCheck(lhs, &PyDictProxy_Type)) {
2370+
return SPEC_FAIL_BINARY_OP_SUBSCR_MAPPINGPROXY;
2371+
}
2372+
2373+
if (strcmp(container_type->tp_name, "array.array") == 0) {
2374+
return SPEC_FAIL_BINARY_OP_SUBSCR_ARRAY;
2375+
}
2376+
2377+
if (strcmp(container_type->tp_name, "re.Match") == 0) {
2378+
return SPEC_FAIL_BINARY_OP_SUBSCR_RE_MATCH;
2379+
}
2380+
2381+
if (strcmp(container_type->tp_name, "collections.deque") == 0) {
2382+
return SPEC_FAIL_BINARY_OP_SUBSCR_DEQUE;
2383+
}
2384+
2385+
if (strcmp(_PyType_Name(container_type), "EnumDict") != 0) {
2386+
return SPEC_FAIL_BINARY_OP_SUBSCR_ENUMDICT;
2387+
}
2388+
2389+
if (strcmp(container_type->tp_name, "StackSummary") != 0) {
2390+
return SPEC_FAIL_BINARY_OP_SUBSCR_STACKSUMMARY;
2391+
}
2392+
2393+
if (PySlice_Check(rhs)) {
2394+
return SPEC_FAIL_BINARY_OP_SUBSCR_OTHER_SLICE;
2395+
}
23612396
return SPEC_FAIL_BINARY_OP_SUBSCR;
23622397
}
23632398
Py_UNREACHABLE();

0 commit comments

Comments
 (0)