Avoid unnecessary overhead in _PyDict_GetItemIdWithError() by calling
_PyDict_GetItem_KnownHash() instead of the more generic PyDict_GetItemWithError(),
since we already know the hash of interned strings.
kv = _PyUnicode_FromId(key); /* borrowed */
if (kv == NULL)
return NULL;
- return PyDict_GetItemWithError(dp, kv);
+ Py_hash_t hash = ((PyASCIIObject *) kv)->hash;
+ assert (hash != -1); /* interned strings have their hash value initialised */
+ return _PyDict_GetItem_KnownHash(dp, kv, hash);
}
PyObject *