This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients methane, serhiy.storchaka, vstinner
Date 2018-01-16.18:18:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1516126685.82.0.467229070634.issue32571@psf.upfronthosting.co.za>
In-reply-to
Content
In issue32544 there was introduced a new private C API function _PyObject_GetAttrWithoutError() which never raises an AttributeError, but returns NULL without error set if an attribute is absent. This allowed to speed up Python builtins hasattr() and getattr() with the default argument.

But C code also could gain a benefit from this. It is common to look up an attribute and silence an AttributeError. Actually it is more common than the opposite case.

The proposed patch adds yet one function, _PyObject_GetAttrIdWithoutError(), and uses these two functions if it is possible to avoid checking an AttributeError after PyObject_GetAttr() and _PyObject_GetAttrId(). This could speed up some code, and also makes it cleaner.
History
Date User Action Args
2018-01-16 18:18:05serhiy.storchakasetrecipients: + serhiy.storchaka, vstinner, methane
2018-01-16 18:18:05serhiy.storchakasetmessageid: <1516126685.82.0.467229070634.issue32571@psf.upfronthosting.co.za>
2018-01-16 18:18:05serhiy.storchakalinkissue32571 messages
2018-01-16 18:18:05serhiy.storchakacreate