8000 gh-121459: Deferred LOAD_ATTR (methods) by Fidget-Spinner · Pull Request #124101 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-121459: Deferred LOAD_ATTR (methods) #124101

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

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
fix default build
  • Loading branch information
Fidget-Spinner committed Sep 15, 2024
commit f0afe98b06fabaf6504fa437e397ad73e927cfa6
8 changes: 7 additions & 1 deletion Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method)
int
_PyObject_GetMethodStackRef(PyObject *obj, PyObject *name, _PyStackRef *method)
{
Copy link
< 10000 /details-menu>
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't have to be in this PR, but we should replace all usages of _PyObject_GetMethod with _PyObject_GetMethodStackRef. Having two similar functions for the same purpose is going to be more difficult to maintain.


#ifdef Py_GIL_DISABLED
int meth_found = 0;

assert(PyStackRef_IsNull(*method));
Expand Down Expand Up @@ -1676,6 +1676,12 @@ _PyObject_GetMethodStackRef(PyObject *obj, PyObject *name, _PyStackRef *method)

_PyObject_SetAttributeErrorContext(obj, name);
return 0;
#else
PyObject *res = NULL;
int err = _PyObject_GetMethod(obj, name, &res);
*method = res == NULL ? PyStackRef_NULL : PyStackRef_FromPyObjectSteal(res);
return err;
#endif
}

/* Generic GetAttr functions - put these in your tp_[gs]etattro slot. */
Expand Down
3 changes: 1 addition & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5618,8 +5618,7 @@ _PyType_LookupStackRef(PyTypeObject *type, PyObject *name, _PyStackRef *result)
assert(type->tp_version_tag);
OBJECT_STAT_INC_COND(type_cache_hits, !is_dunder_name(name));
OBJECT_STAT_INC_COND(type_cache_dunder_hits, is_dunder_name(name));
Py_XINCREF(entry->value);
return entry->value;
*result = PyStackRef_FromPyObjectNew(entry->value);
}
#endif
OBJECT_STAT_INC_COND(type_cache_misses, !is_dunder_name(name));
Expand Down
Loading
0