Skip to content

Use _PyObject_LookupAttr() instead of PyObject_GetAttr() #106303

Closed
@serhiy-storchaka

Description

@serhiy-storchaka

PyObject_GetAttr() followed by PyErr_ExceptionMatches(PyExc_AttributeError) and PyErr_Clear() can be replaced with _PyObject_LookupAttr(). It is faster, because it avoids raising the AttributeError exception which later be caught and dropped at first place. And it leads to simpler code. Most of code already uses _PyObject_LookupAttr(), but some new code was added recently which still use the old idiom.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions