mirror of https://github.com/pyodide/pyodide.git
PERF Don't format attribute error in JsProxy_GetAttr (#4961)
This initial `PyObject_GenericGetAttr` is expected to fail, but it formats an expensive AttributeError whenever it does. The internal method `_PyObject_GenericGetAttrWithDict` has a `suppress` argument that makes it not do this. This saves between 40% and 70% of the time spent in JsProxy_GetAttr depending on the return value.
This commit is contained in:
parent
96dde9d04c
commit
2287b0a45d
|
@ -371,11 +371,10 @@ EM_JS_VAL(JsVal, JsProxy_GetAttr_js, (JsVal jsobj, const char* ptrkey), {
|
|||
static PyObject*
|
||||
JsProxy_GetAttr(PyObject* self, PyObject* attr)
|
||||
{
|
||||
PyObject* result = PyObject_GenericGetAttr(self, attr);
|
||||
if (result != NULL || !PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
||||
PyObject* result = _PyObject_GenericGetAttrWithDict(self, attr, NULL, 1);
|
||||
if (result != NULL || PyErr_Occurred()) {
|
||||
return result;
|
||||
}
|
||||
PyErr_Clear();
|
||||
|
||||
bool success = false;
|
||||
JsVal jsresult = JS_NULL;
|
||||
|
|
Loading…
Reference in New Issue