Skip to content
Merged
Prev Previous commit
Next Next commit
perf tuning
Including the revert: 2e7bb29
  • Loading branch information
neonene authored Oct 9, 2024
commit c02f0a6f6692705ddb6f24a84bd1f77e3cda4c19
13 changes: 6 additions & 7 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5283,8 +5283,9 @@ get_base_by_token_recursive(PyObject *bases, void *token)
res = base;
break;
}
res = get_base_by_token_recursive(lookup_tp_bases(base), token);
if (res != NULL) {
base = get_base_by_token_recursive(lookup_tp_bases(base), token);
if (base != NULL) {
res = base;
break;
}
}
Expand Down Expand Up @@ -5323,7 +5324,7 @@ PyType_GetBaseByToken(PyTypeObject *type, void *token, PyTypeObject **result)
base = get_base_by_token_recursive(lookup_tp_bases(type), token);
if (base != NULL) {
// Copying the given type can cause a slowdown,
// unlike overwriting below.
// unlike the overwrite below.
type = base;
goto found;
}
Expand All @@ -5337,10 +5338,8 @@ PyType_GetBaseByToken(PyTypeObject *type, void *token, PyTypeObject **result)
Py_ssize_t n = PyTuple_GET_SIZE(mro);
for (Py_ssize_t i = 1; i < n; i++) {
PyTypeObject *base = (PyTypeObject *)PyTuple_GET_ITEM(mro, i);
if (!_PyType_HasFeature(base, Py_TPFLAGS_HEAPTYPE)) {
continue;
}
if (((PyHeapTypeObject*)base)->ht_token == token) {
if (_PyType_HasFeature(base, Py_TPFLAGS_HEAPTYPE)
&& ((PyHeapTypeObject*)base)->ht_token == token) {
type = base;
goto found;
}
Expand Down