Skip to content

Commit c5d0517

Browse files
authored
Add more FOR_ITER specialization stats (GH-32151)
1 parent 9331087 commit c5d0517

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

Python/specialize.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,12 @@ miss_counter_start(void) {
477477
#define SPEC_FAIL_FOR_ITER_DICT_ITEMS 21
478478
#define SPEC_FAIL_FOR_ITER_DICT_VALUES 22
479479
#define SPEC_FAIL_FOR_ITER_ENUMERATE 23
480+
#define SPEC_FAIL_FOR_ITER_MAP 24
481+
#define SPEC_FAIL_FOR_ITER_ZIP 25
482+
#define SPEC_FAIL_FOR_ITER_SEQ_ITER 26
483+
#define SPEC_FAIL_FOR_ITER_REVERSED_LIST 27
484+
#define SPEC_FAIL_FOR_ITER_CALLABLE 28
485+
#define SPEC_FAIL_FOR_ITER_ASCII_STRING 29
480486

481487
// UNPACK_SEQUENCE
482488

@@ -2051,10 +2057,28 @@ int
20512057
if (t == &PyEnum_Type) {
20522058
return SPEC_FAIL_FOR_ITER_ENUMERATE;
20532059
}
2054-
2055-
if (strncmp(t->tp_name, "itertools", 8) == 0) {
2060+
if (t == &PyMap_Type) {
2061+
return SPEC_FAIL_FOR_ITER_MAP;
2062+
}
2063+
if (t == &PyZip_Type) {
2064+
return SPEC_FAIL_FOR_ITER_ZIP;
2065+
}
2066+
if (t == &PySeqIter_Type) {
2067+
return SPEC_FAIL_FOR_ITER_SEQ_ITER;
2068+
}
2069+
if (t == &PyListRevIter_Type) {
2070+
return SPEC_FAIL_FOR_ITER_REVERSED_LIST;
2071+
}
2072+
if (t == &_PyUnicodeASCIIIter_Type) {
2073+
return SPEC_FAIL_FOR_ITER_ASCII_STRING;
2074+
}
2075+
const char *name = t->tp_name;
2076+
if (strncmp(name, "itertools", 9) == 0) {
20562077
return SPEC_FAIL_FOR_ITER_ITERTOOLS;
20572078
}
2079+
if (strncmp(name, "callable_iterator", 17) == 0) {
2080+
return SPEC_FAIL_FOR_ITER_CALLABLE;
2081+
}
20582082
return SPEC_FAIL_OTHER;
20592083
}
20602084

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy