Author serhiy.storchaka
Recipients eelizondo, josh.r, serhiy.storchaka, vstinner
Date 2018-12-10.19:25:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1544469908.95.0.788709270274.issue35438@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-12-10 19:25:08serhiy.storchakasetrecipients: + serhiy.storchaka, vstinner, josh.r, eelizondo
2018-12-10 19:25:08serhiy.storchakasetmessageid: <1544469908.95.0.788709270274.issue35438@psf.upfronthosting.co.za>
2018-12-10 19:25:08serhiy.storchakalinkissue35438 messages
2018-12-10 19:25:08serhiy.storchakacreate