-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
gh-106303: Use _PyObject_LookupAttr() instead of PyObject_GetAttr() #106304
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
Conversation
…tr() It simplifies and speed up the code.
return -1; | ||
PyObject *value; | ||
int res = _PyObject_LookupAttr(wrapped, name, &value); | ||
if (value != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding an assert before reassignment?
assert(res > 0);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not necessary in many other cases where a similar idiom is used.
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
Sorry @serhiy-storchaka, I had trouble checking out the |
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
GH-106568 is a backport of this pull request to the 3.12 branch. |
…t_GetAttr() (pythonGH-106304) It simplifies and speed up the code.. (cherry picked from commit 93d292c) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-106569 is a backport of this pull request to the 3.11 branch. |
…t_GetAttr() (pythonGH-106304) It simplifies and speed up the code. (cherry picked from commit 93d292c) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
It simplifies and speed up the code.