@@ -100,43 +100,43 @@ protected Object readFromDynamicStorage(PythonObject object, Object key,
100
100
return readAttributeFromDynamicObjectNode .execute (object .getStorage (), key );
101
101
}
102
102
103
+ private static Object readDirectlyFromBuiltinDict (PHashingCollection dict , String key ,
104
+ HashingCollectionNodes .GetDictStorageNode getDictStorage ,
105
+ HashingStorageNodes .GetItemNode getItemNode ) {
106
+ // note that we don't need to pass the state here - string keys are hashable by definition
107
+ Object value = getItemNode .execute (null , getDictStorage .execute (dict ), key );
108
+ if (value == null ) {
109
+ return PNone .NO_VALUE ;
110
+ } else {
111
+ return value ;
112
+ }
113
+ }
114
+
103
115
// special case for the very common module attribute read
104
116
@ Specialization (guards = {
105
117
"cachedObject == object" ,
106
118
"cachedObject.getDict() == cachedDict" ,
107
- "hasBuiltinDict(cachedObject, isBuiltinDict)" ,
119
+ "hasBuiltinDict(cachedObject, isBuiltinDict, isBuiltinMappingproxy )" ,
108
120
}, assumptions = "singleContextAssumption" , limit = "1" )
109
121
protected Object readFromBuiltinModuleDict (@ SuppressWarnings ("unused" ) PythonModule object , String key ,
110
122
@ SuppressWarnings ("unused" ) @ Cached ("object" ) PythonModule cachedObject ,
111
123
@ SuppressWarnings ("unused" ) @ Cached ("cachedObject.getDict()" ) PHashingCollection cachedDict ,
112
124
@ SuppressWarnings ("unused" ) @ Cached ("singleContextAssumption()" ) Assumption singleContextAssumption ,
113
125
@ Cached HashingCollectionNodes .GetDictStorageNode getDictStorage ,
114
126
@ SuppressWarnings ("unused" ) @ Cached IsBuiltinClassProfile isBuiltinDict ,
127
+ @ SuppressWarnings ("unused" ) @ Cached IsBuiltinClassProfile isBuiltinMappingproxy ,
115
128
@ Cached HashingStorageNodes .GetItemNode getItemNode ) {
116
- Object value = getItemNode .execute (null , getDictStorage .execute (cachedDict ), key );
117
- if (value == null ) {
118
- return PNone .NO_VALUE ;
119
- } else {
120
- return value ;
121
- }
129
+ return readDirectlyFromBuiltinDict (cachedDict , key , getDictStorage , getItemNode );
122
130
}
123
131
124
132
// read from a builtin dict
125
- @ Specialization (guards = {
126
- "!isHiddenKey(key)" ,
127
- "hasBuiltinDict(object, isBuiltinDict)" ,
128
- })
133
+ @ Specialization (guards = {"!isHiddenKey(key)" , "hasBuiltinDict(object, isBuiltinDict, isBuiltinMappingproxy)" })
129
134
protected Object readFromBuiltinDict (PythonObject object , String key ,
130
135
@ Cached HashingCollectionNodes .GetDictStorageNode getDictStorage ,
131
136
@ SuppressWarnings ("unused" ) @ Cached IsBuiltinClassProfile isBuiltinDict ,
137
+ @ SuppressWarnings ("unused" ) @ Cached IsBuiltinClassProfile isBuiltinMappingproxy ,
132
138
@ Cached ("create()" ) HashingStorageNodes .GetItemNode getItemNode ) {
133
- // note that we don't need to pass the state here - string keys are hashable by definition
134
- Object value = getItemNode .execute (null , getDictStorage .execute (object .getDict ()), key );
135
- if (value == null ) {
136
- return PNone .NO_VALUE ;
137
- } else {
138
- return value ;
139
- }
139
+ return readDirectlyFromBuiltinDict (object .getDict (), key , getDictStorage , getItemNode );
140
140
}
141
141
142
142
// read from the Dict
0 commit comments