8000 bpo-44337: Port LOAD_ATTR to PEP 659 adaptive interpreter by markshannon · Pull Request #26595 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-44337: Port LOAD_ATTR to PEP 659 adaptive interpreter #26595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 10, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

8000
Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use _PyDict_GetItemHint instead of _Py_dict_lookup to determine index…
… in dictionary when specializing.
  • Loading branch information
markshannon committed Jun 8, 2021
commit f9e999ccbba871a5998fcb3c9fea4a5c0b679ba5
19 changes: 10 additions & 9 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,26 +227,27 @@ specialize_module_load_attr(
_PyAdaptiveEntry *cache0, _PyLoadAttrCache *cache1)
{
PyModuleObject *m = (PyModuleObject *)owner;
PyObject *attr, *getattr;
PyObject *value = NULL;
PyObject *getattr;
_Py_IDENTIFIER(__getattr__);
PyDictObject *dict = (PyDictObject *)m->md_dict;
if (dict == NULL) {
return -1;
}
getattr = _PyDict_GetItemIdWithError(m->md_dict, &PyId___getattr__);
if (PyErr_Occurred()) {
PyErr_Clear();
if (dict->ma_keys->dk_kind != DICT_KEYS_UNICODE) {
return -1;
}
if (getattr != NULL) {
getattr = _PyUnicode_FromId(&PyId___getattr__); /* borrowed */
if (getattr == NULL) {
PyErr_Clear();
return -1;
}
Py_hash_t hash = PyObject_Hash(name);
if (hash == -1) {
PyErr_Clear();
Py_ssize_t index = _PyDict_GetItemHint(dict, getattr, -1, &value);
assert(index != DKIX_ERROR);
if (index != DKIX_EMPTY) {
return -1;
}
Py_ssize_t index = _Py_dict_lookup(dict, name, hash, &attr);
index = _PyDict_GetItemHint(dict, name, -1, &value);
assert (index != DKIX_ERROR);
if (index != (uint16_t)index) {
return -1;
Expand Down
0