Nathaniel Smith <n...@pobox.com> added the comment:

Can I ask why this is a private API? It's extremely useful for extension 
modules too. For example, numpy has been carrying around a reimplementation of 
PyObject_GetAttr for years, exactly to avoid the cost of creating an 
AttributeError exception in common cases:

https://github.com/numpy/numpy/blob/master/numpy/core/src/private/get_attr_string.h

(To emphasize the similarity, note that the code above used to be called 
PyArray_GetAttrString_SuppressException, until a refactoring last year: 
https://github.com/numpy/numpy/commit/69a423b23492ecf8471efc4e59ab8a93b03d8454. 
It's always been specifically used for looking up numpy-specific special 
methods like __array__, __array_interface__, etc., though, which is why it can 
get away with those shortcuts -- we know they usually aren't defined.)

----------
nosy: +njs

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32571>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to