@@ -326,18 +326,14 @@ PyObject *CPyDict_Copy(PyObject *dict) {
326326
327327PyObject * CPyDict_GetKeysIter (PyObject * dict ) {
328328 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 );
332330 }
333331 return PyObject_GetIter (dict );
334332}
335333
336334PyObject * CPyDict_GetItemsIter (PyObject * dict ) {
337335 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 );
341337 }
342338 _Py_IDENTIFIER (items );
343339 PyObject * name = _PyUnicode_FromId (& PyId_items ); /* borrowed */
@@ -506,66 +502,32 @@ PyObject *CPyDict_GetItemUnsafe(PyObject *dict, PyObject *key) {
506502 return res ;
507503}
508504
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-
555505PyObject * 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.
557507 Py_INCREF (dict );
558508 return dict ;
559509}
560510
561511PyObject * 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.
563513 Py_INCREF (dict );
564514 return dict ;
565515}
566516
567517PyObject * 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.
569519 Py_INCREF (dict );
570520 return dict ;
571521}
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