@@ -258,30 +258,6 @@ extern "C" PyObject* PyDict_New() noexcept {
258
258
return new BoxedDict ();
259
259
}
260
260
261
- // We don't assume that dicts passed to PyDict are necessarily dicts, since there are a couple places
262
- // that we provide dict-like objects instead of proper dicts.
263
- // The performance should hopefully be comparable to the CPython fast case, since we can use
264
- // runtimeICs.
265
- extern " C" int PyDict_SetItem (PyObject* mp, PyObject* _key, PyObject* _item) noexcept {
266
- ASSERT (PyDict_Check (mp) || mp->cls == attrwrapper_cls, " %s" , getTypeName (mp));
267
-
268
- assert (mp);
269
- Box* b = static_cast <Box*>(mp);
270
- Box* key = static_cast <Box*>(_key);
271
- Box* item = static_cast <Box*>(_item);
272
-
273
- assert (key);
274
- assert (item);
275
-
276
- try {
277
- setitem (b, key, item);
278
- } catch (ExcInfo e) {
279
- setCAPIException (e);
280
- return -1 ;
281
- }
282
- return 0 ;
283
- }
284
-
285
261
extern " C" int PyDict_SetItemString (PyObject* mp, const char * key, PyObject* item) noexcept {
286
262
Box* key_s;
287
263
try {
@@ -383,6 +359,33 @@ Box* dictSetitem(BoxedDict* self, Box* k, Box* v) {
383
359
return None;
384
360
}
385
361
362
+ // We don't assume that dicts passed to PyDict are necessarily dicts, since there are a couple places
363
+ // that we provide dict-like objects instead of proper dicts.
364
+ // The performance should hopefully be comparable to the CPython fast case, since we can use
365
+ // runtimeICs.
366
+ extern " C" int PyDict_SetItem (PyObject* mp, PyObject* _key, PyObject* _item) noexcept {
367
+ ASSERT (PyDict_Check (mp) || mp->cls == attrwrapper_cls, " %s" , getTypeName (mp));
368
+
369
+ assert (mp);
370
+ Box* b = static_cast <Box*>(mp);
371
+ Box* key = static_cast <Box*>(_key);
372
+ Box* item = static_cast <Box*>(_item);
373
+
374
+ assert (key);
375
+ assert (item);
376
+
377
+ try {
378
+ if (PyDict_Check (mp))
379
+ dictSetitem ((BoxedDict*)b, key, item);
380
+ else
381
+ setitem (b, key, item);
382
+ } catch (ExcInfo e) {
383
+ setCAPIException (e);
384
+ return -1 ;
385
+ }
386
+ return 0 ;
387
+ }
388
+
386
389
Box* dictDelitem (BoxedDict* self, Box* k) {
387
390
if (!PyDict_Check (self))
388
391
raiseExcHelper (TypeError, " descriptor '__delitem__' requires a 'dict' object but received a '%s'" ,
0 commit comments