Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:
There is nothing wrong with using private C API in the implementation of standard CPython extensions. This API was designed for this. In contrary, there are problems with your code: * It is less efficient. String objects are created and destroyed twice per every function call, in PyObject_HasAttrString() and in PyObject_CallMethod(). Format string is parsed in PyObject_CallMethod(). Other temporary objects are created and destroyed. * It uses inherently broken PyObject_HasAttrString(). PyObject_HasAttrString() swallows exceptions (for example a MemoryError raised when create a temporary string object) and can return an incorrect result. * It is not equivalent with the existing code. For example it does not work properly if the dunder method is a static method. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35438> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com