@@ -326,18 +326,14 @@ PyObject *CPyDict_Copy(PyObject *dict) {
326
326
327
327
PyObject * CPyDict_GetKeysIter (PyObject * dict ) {
328
328
if (PyDict_CheckExact (dict )) {
329
- // Return dict itself to indicate we can use fast path instead.
330
- Py_INCREF (dict );
331
- return dict ;
329
+ return CPyDict_GetKeysIterUnsafe (dict );
332
330
}
333
331
return PyObject_GetIter (dict );
334
332
}
335
333
336
334
PyObject * CPyDict_GetItemsIter (PyObject * dict ) {
337
335
if (PyDict_CheckExact (dict )) {
338
- // Return dict itself to indicate we can use fast path instead.
339
- Py_INCREF (dict );
340
- return dict ;
336
+ return CPyDict_GetItemsIterUnsafe (dict );
341
337
}
342
338
_Py_IDENTIFIER (items );
343
339
PyObject * name = _PyUnicode_FromId (& PyId_items ); /* borrowed */
@@ -506,66 +502,32 @@ PyObject *CPyDict_GetItemUnsafe(PyObject *dict, PyObject *key) {
506
502
return res ;
507
503
}
508
504
509
- int CPyDict_SetItemUnsafe (PyObject * dict , PyObject * key , PyObject * value ) {
510
- // No type check, direct call
511
- return PyDict_SetItem (dict , key , value );
512
- }
513
-
514
- PyObject * CPyDict_KeysViewUnsafe (PyObject * dict ) {
515
- // No type check, direct call
516
- return _CPyDictView_New (dict , & PyDictKeys_Type );
517
- }
518
-
519
- PyObject * CPyDict_ValuesViewUnsafe (PyObject * dict ) {
520
- // No type check, direct call
521
- return _CPyDictView_New (dict , & PyDictValues_Type );
522
- }
523
-
524
- PyObject * CPyDict_ItemsViewUnsafe (PyObject * dict ) {
525
- // No type check, direct call
526
- return _CPyDictView_New (dict , & PyDictItems_Type );
527
- }
528
-
529
- PyObject * CPyDict_KeysUnsafe (PyObject * dict ) {
530
- // No type check, direct call
531
- return PyDict_Keys (dict );
532
- }
533
-
534
- PyObject * CPyDict_ValuesUnsafe (PyObject * dict ) {
535
- // No type check, direct call
536
- return PyDict_Values (dict );
537
- }
538
-
539
- PyObject * CPyDict_ItemsUnsafe (PyObject * dict ) {
540
- // No type check, direct call
541
- return PyDict_Items (dict );
542
- }
543
-
544
- char CPyDict_ClearUnsafe (PyObject * dict ) {
545
- // No type check, direct call
546
- PyDict_Clear (dict );
547
- return 1 ;
548
- }
549
-
550
- PyObject * CPyDict_CopyUnsafe (PyObject * dict ) {
551
- // No type check, direct call
552
- return PyDict_Copy (dict );
553
- }
554
-
555
505
PyObject * CPyDict_GetKeysIterUnsafe (PyObject * dict ) {
556
- // No type check, direct call
506
+ // No type check, direct call. Returns dict directly to indicate fast path should be used.
557
507
Py_INCREF (dict );
558
508
return dict ;
559
509
}
560
510
561
511
PyObject * CPyDict_GetItemsIterUnsafe (PyObject * dict ) {
562
- // No type check, direct call
512
+ // No type check, direct call. Returns dict directly to indicate fast path should be used.
563
513
Py_INCREF (dict );
564
514
return dict ;
565
515
}
566
516
567
517
PyObject * CPyDict_GetValuesIterUnsafe (PyObject * dict ) {
568
- // No type check, direct call
518
+ // No type check, direct call. Returns dict directly to indicate fast path should be used.
569
519
Py_INCREF (dict );
570
520
return dict ;
571
521
}
522
+
523
+ PyObject * CPyDict_KeysViewUnsafe (PyObject * dict ) {
524
+ return _CPyDictView_New (dict , & PyDictKeys_Type );
525
+ }
526
+
527
+ PyObject * CPyDict_ValuesViewUnsafe (PyObject * dict ) {
528
+ return _CPyDictView_New (dict , & PyDictValues_Type );
529
+ }
530
+
531
+ PyObject * CPyDict_ItemsViewUnsafe (PyObject * dict ) {
532
+ return _CPyDictView_New (dict , & PyDictItems_Type );
533
+ }
0 commit comments