Use identifier API for PyObject_GetAttrString.
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 72e5815..cd35037 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2699,13 +2699,15 @@
 bytearray_reduce(PyByteArrayObject *self)
 {
     PyObject *latin1, *dict;
+    _Py_identifier(__dict__);
+
     if (self->ob_bytes)
         latin1 = PyUnicode_DecodeLatin1(self->ob_bytes,
                                         Py_SIZE(self), NULL);
     else
         latin1 = PyUnicode_FromString("");
 
-    dict = PyObject_GetAttrString((PyObject *)self, "__dict__");
+    dict = _PyObject_GetAttrId((PyObject *)self, &PyId___dict__);
     if (dict == NULL) {
         PyErr_Clear();
         dict = Py_None;
diff --git a/Objects/classobject.c b/Objects/classobject.c
index b52a209..40161ef 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -14,6 +14,8 @@
 #define PyMethod_MAXFREELIST 256
 #endif
 
+_Py_identifier(__name__);
+
 PyObject *
 PyMethod_Function(PyObject *im)
 {
@@ -226,7 +228,7 @@
         return NULL;
     }
 
-    funcname = PyObject_GetAttrString(func, "__name__");
+    funcname = _PyObject_GetAttrId(func, &PyId___name__);
     if (funcname == NULL) {
         if (!PyErr_ExceptionMatches(PyExc_AttributeError))
             return NULL;
@@ -240,7 +242,7 @@
     if (klass == NULL)
         klassname = NULL;
     else {
-        klassname = PyObject_GetAttrString(klass, "__name__");
+        klassname = _PyObject_GetAttrId(klass, &PyId___name__);
         if (klassname == NULL) {
             if (!PyErr_ExceptionMatches(PyExc_AttributeError))
                 return NULL;
@@ -542,7 +544,7 @@
         return NULL;
     }
 
-    funcname = PyObject_GetAttrString(func, "__name__");
+    funcname = _PyObject_GetAttrId(func, &PyId___name__);
     if (funcname == NULL) {
         if (!PyErr_ExceptionMatches(PyExc_AttributeError))
             return NULL;
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 046eebd..d664789 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1299,7 +1299,8 @@
 
     /* if no docstring given and the getter has one, use that one */
     if ((doc == NULL || doc == Py_None) && get != NULL) {
-        PyObject *get_doc = PyObject_GetAttrString(get, "__doc__");
+        _Py_identifier(__doc__);
+        PyObject *get_doc = _PyObject_GetAttrId(get, &PyId___doc__);
         if (get_doc) {
             if (Py_TYPE(self) == &PyProperty_Type) {
                 Py_XDECREF(prop->prop_doc);
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index f3006d0..324e2ee 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -59,8 +59,9 @@
     {
         PyObject *reader;
         PyObject *args;
+        _Py_identifier(readline);
 
-        reader = PyObject_GetAttrString(f, "readline");
+        reader = _PyObject_GetAttrId(f, &PyId_readline);
         if (reader == NULL)
             return NULL;
         if (n <= 0)
@@ -127,11 +128,13 @@
 PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
 {
     PyObject *writer, *value, *args, *result;
+    _Py_identifier(write);
+
     if (f == NULL) {
         PyErr_SetString(PyExc_TypeError, "writeobject with NULL file");
         return -1;
     }
-    writer = PyObject_GetAttrString(f, "write");
+    writer = _PyObject_GetAttrId(f, &PyId_write);
     if (writer == NULL)
         return -1;
     if (flags & Py_PRINT_RAW) {
@@ -194,11 +197,12 @@
 {
     int fd;
     PyObject *meth;
+    _Py_identifier(fileno);
 
     if (PyLong_Check(o)) {
         fd = PyLong_AsLong(o);
     }
-    else if ((meth = PyObject_GetAttrString(o, "fileno")) != NULL)
+    else if ((meth = _PyObject_GetAttrId(o, &PyId_fileno)) != NULL)
     {
         PyObject *fno = PyEval_CallObject(meth, NULL);
         Py_DECREF(meth);
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 4b4f9d1..32c4b9e 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -415,8 +415,9 @@
 static PyObject *
 module_dir(PyObject *self, PyObject *args)
 {
+    _Py_identifier(__dict__);
     PyObject *result = NULL;
-    PyObject *dict = PyObject_GetAttrString(self, "__dict__");
+    PyObject *dict = _PyObject_GetAttrId(self, &PyId___dict__);
 
     if (dict != NULL) {
         if (PyDict_Check(dict))
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 34d8204..8f6325a 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1933,6 +1933,7 @@
 set_reduce(PySetObject *so)
 {
     PyObject *keys=NULL, *args=NULL, *result=NULL, *dict=NULL;
+    _Py_identifier(__dict__);
 
     keys = PySequence_List((PyObject *)so);
     if (keys == NULL)
@@ -1940,7 +1941,7 @@
     args = PyTuple_Pack(1, keys);
     if (args == NULL)
         goto done;
-    dict = PyObject_GetAttrString((PyObject *)so, "__dict__");
+    dict = _PyObject_GetAttrId((PyObject *)so, &PyId___dict__);
     if (dict == NULL) {
         PyErr_Clear();
         dict = Py_None;
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index f94dfbf..526ad4c 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -35,6 +35,9 @@
 static struct method_cache_entry method_cache[1 << MCACHE_SIZE_EXP];
 static unsigned int next_version_tag = 0;
 
+_Py_identifier(__dict__);
+_Py_identifier(__class__);
+
 unsigned int
 PyType_ClearCache(void)
 {
@@ -1281,7 +1284,8 @@
 static PyObject *
 class_name(PyObject *cls)
 {
-    PyObject *name = PyObject_GetAttrString(cls, "__name__");
+    _Py_identifier(__name__);
+    PyObject *name = _PyObject_GetAttrId(cls, &PyId___name__);
     if (name == NULL) {
         PyErr_Clear();
         Py_XDECREF(name);
@@ -1709,15 +1713,14 @@
 static PyObject *
 get_dict_descriptor(PyTypeObject *type)
 {
-    static PyObject *dict_str;
+    PyObject *dict_str;
     PyObject *descr;
 
-    if (dict_str == NULL) {
-        dict_str = PyUnicode_InternFromString("__dict__");
-        if (dict_str == NULL)
-            return NULL;
-    }
+    dict_str = _PyUnicode_FromId(&PyId___dict__);
+    if (dict_str == NULL)
+        return NULL;
     descr = _PyType_Lookup(type, dict_str);
+    Py_DECREF(dict_str);
     if (descr == NULL || !PyDescr_IsData(descr))
         return NULL;
 
@@ -2596,12 +2599,13 @@
 {
     PyObject *classdict;
     PyObject *bases;
+    _Py_identifier(__bases__);
 
     assert(PyDict_Check(dict));
     assert(aclass);
 
     /* Merge in the type's dict (if any). */
-    classdict = PyObject_GetAttrString(aclass, "__dict__");
+    classdict = _PyObject_GetAttrId(aclass, &PyId___dict__);
     if (classdict == NULL)
         PyErr_Clear();
     else {
@@ -2612,7 +2616,7 @@
     }
 
     /* Recursively merge in the base types' (if any) dicts. */
-    bases = PyObject_GetAttrString(aclass, "__bases__");
+    bases = _PyObject_GetAttrId(aclass, &PyId___bases__);
     if (bases == NULL)
         PyErr_Clear();
     else {
@@ -3540,7 +3544,7 @@
     PyObject *itsclass = NULL;
 
     /* Get __dict__ (which may or may not be a real dict...) */
-    dict = PyObject_GetAttrString(self, "__dict__");
+    dict = _PyObject_GetAttrId(self, &PyId___dict__);
     if (dict == NULL) {
         PyErr_Clear();
         dict = PyDict_New();
@@ -3560,7 +3564,7 @@
         goto error;
 
     /* Merge in attrs reachable from its class. */
-    itsclass = PyObject_GetAttrString(self, "__class__");
+    itsclass = _PyObject_GetAttrId(self, &PyId___class__);
     if (itsclass == NULL)
         /* XXX(tomer): Perhaps fall back to obj->ob_type if no
                        __class__ exists? */
@@ -6304,16 +6308,15 @@
     }
     else {
         /* Try the slow way */
-        static PyObject *class_str = NULL;
+        PyObject *class_str = NULL;
         PyObject *class_attr;
 
-        if (class_str == NULL) {
-            class_str = PyUnicode_FromString("__class__");
-            if (class_str == NULL)
-                return NULL;
-        }
+        class_str = _PyUnicode_FromId(&PyId___class__);
+        if (class_str == NULL)
+            return NULL;
 
         class_attr = PyObject_GetAttr(obj, class_str);
+        Py_DECREF(class_str);
 
         if (class_attr != NULL &&
             PyType_Check(class_attr) &&
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index 594f0ea..374e720 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -157,11 +157,12 @@
 weakref_repr(PyWeakReference *self)
 {
     PyObject *name, *repr;
+    _Py_identifier(__name__);
 
     if (PyWeakref_GET_OBJECT(self) == Py_None)
         return PyUnicode_FromFormat("<weakref at %p; dead>", self);
 
-    name = PyObject_GetAttrString(PyWeakref_GET_OBJECT(self), "__name__");
+    name = _PyObject_GetAttrId(PyWeakref_GET_OBJECT(self), &PyId___name__);
     if (name == NULL || !PyUnicode_Check(name)) {
         if (name == NULL)
             PyErr_Clear();