@@ -826,8 +826,9 @@ _Pickler_SetProtocol(PicklerObject *self, PyObject *proto_obj,
826826static int
827827_Pickler_SetOutputStream (PicklerObject * self , PyObject * file )
828828{
829+ _Py_identifier (write );
829830 assert (file != NULL );
830- self -> write = PyObject_GetAttrString (file , "write" );
831+ self -> write = _PyObject_GetAttrId (file , & PyId_write );
831832 if (self -> write == NULL ) {
832833 if (PyErr_ExceptionMatches (PyExc_AttributeError ))
833834 PyErr_SetString (PyExc_TypeError ,
@@ -1173,15 +1174,19 @@ _Unpickler_New(void)
11731174static int
11741175_Unpickler_SetInputStream (UnpicklerObject * self , PyObject * file )
11751176{
1176- self -> peek = PyObject_GetAttrString (file , "peek" );
1177+ _Py_identifier (peek );
1178+ _Py_identifier (read );
1179+ _Py_identifier (readline );
1180+
1181+ self -> peek = _PyObject_GetAttrId (file , & PyId_peek );
11771182 if (self -> peek == NULL ) {
11781183 if (PyErr_ExceptionMatches (PyExc_AttributeError ))
11791184 PyErr_Clear ();
11801185 else
11811186 return -1 ;
11821187 }
1183- self -> read = PyObject_GetAttrString (file , "read" );
1184- self -> readline = PyObject_GetAttrString (file , "readline" );
1188+ self -> read = _PyObject_GetAttrId (file , & PyId_read );
1189+ self -> readline = _PyObject_GetAttrId (file , & PyId_readline );
11851190 if (self -> readline == NULL || self -> read == NULL ) {
11861191 if (PyErr_ExceptionMatches (PyExc_AttributeError ))
11871192 PyErr_SetString (PyExc_TypeError ,
@@ -3390,6 +3395,7 @@ Pickler_init(PicklerObject *self, PyObject *args, PyObject *kwds)
33903395 PyObject * file ;
33913396 PyObject * proto_obj = NULL ;
33923397 PyObject * fix_imports = Py_True ;
3398+ _Py_identifier (persistent_id );
33933399
33943400 if (!PyArg_ParseTupleAndKeywords (args , kwds , "O|OO:Pickler" ,
33953401 kwlist , & file , & proto_obj , & fix_imports ))
@@ -3425,9 +3431,9 @@ Pickler_init(PicklerObject *self, PyObject *args, PyObject *kwds)
34253431 self -> fast_nesting = 0 ;
34263432 self -> fast_memo = NULL ;
34273433 self -> pers_func = NULL ;
3428- if (PyObject_HasAttrString ((PyObject * )self , "persistent_id" )) {
3429- self -> pers_func = PyObject_GetAttrString ((PyObject * )self ,
3430- "persistent_id" );
3434+ if (_PyObject_HasAttrId ((PyObject * )self , & PyId_persistent_id )) {
3435+ self -> pers_func = _PyObject_GetAttrId ((PyObject * )self ,
3436+ & PyId_persistent_id );
34313437 if (self -> pers_func == NULL )
34323438 return -1 ;
34333439 }
@@ -4935,8 +4941,9 @@ do_append(UnpicklerObject *self, Py_ssize_t x)
49354941 }
49364942 else {
49374943 PyObject * append_func ;
4944+ _Py_identifier (append );
49384945
4939- append_func = PyObject_GetAttrString (list , "append" );
4946+ append_func = _PyObject_GetAttrId (list , & PyId_append );
49404947 if (append_func == NULL )
49414948 return -1 ;
49424949 for (i = x ; i < len ; i ++ ) {
@@ -5023,6 +5030,7 @@ load_build(UnpicklerObject *self)
50235030 PyObject * state , * inst , * slotstate ;
50245031 PyObject * setstate ;
50255032 int status = 0 ;
5033+ _Py_identifier (__setstate__ );
50265034
50275035 /* Stack is ... instance, state. We want to leave instance at
50285036 * the stack top, possibly mutated via instance.__setstate__(state).
@@ -5036,7 +5044,7 @@ load_build(UnpicklerObject *self)
50365044
50375045 inst = self -> stack -> data [Py_SIZE (self -> stack ) - 1 ];
50385046
5039- setstate = PyObject_GetAttrString (inst , "__setstate__" );
5047+ setstate = _PyObject_GetAttrId (inst , & PyId___setstate__ );
50405048 if (setstate == NULL ) {
50415049 if (PyErr_ExceptionMatches (PyExc_AttributeError ))
50425050 PyErr_Clear ();
@@ -5079,12 +5087,13 @@ load_build(UnpicklerObject *self)
50795087 PyObject * dict ;
50805088 PyObject * d_key , * d_value ;
50815089 Py_ssize_t i ;
5090+ _Py_identifier (__dict__ );
50825091
50835092 if (!PyDict_Check (state )) {
50845093 PyErr_SetString (UnpicklingError , "state is not a dictionary" );
50855094 goto error ;
50865095 }
5087- dict = PyObject_GetAttrString (inst , "__dict__" );
5096+ dict = _PyObject_GetAttrId (inst , & PyId___dict__ );
50885097 if (dict == NULL )
50895098 goto error ;
50905099
@@ -5584,8 +5593,9 @@ Unpickler_init(UnpicklerObject *self, PyObject *args, PyObject *kwds)
55845593 return -1 ;
55855594
55865595 if (PyObject_HasAttrString ((PyObject * )self , "persistent_load" )) {
5587- self -> pers_func = PyObject_GetAttrString ((PyObject * )self ,
5588- "persistent_load" );
5596+ _Py_identifier (persistent_load );
5597+ self -> pers_func = _PyObject_GetAttrId ((PyObject * )self ,
5598+ & PyId_persistent_load );
55895599 if (self -> pers_func == NULL )
55905600 return -1 ;
55915601 }
0 commit comments