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.

classification
Title: Use LOAD_METHOD optimization in CallMethod C API functions
Type: Stage: resolved
Components: Extension Modules Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, methane, msullivan, serhiy.storchaka, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2019-05-23 00:32 by msullivan, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13516 merged msullivan, 2019-05-23 00:36
Messages (4)
msg343259 - (view) Author: Michael J. Sullivan (msullivan) * Date: 2019-05-23 00:32
The different varieties of PyObject_CallMethod* routines all operate by doing a PyObject_GetAttr to fetch an object to call. It seems likely to be worthwhile to take advantage of the LOAD_METHOD optimization that avoids creating a bound method object when calling a method.
msg343290 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-05-23 12:16
I want to wait this until PEP 590 is implemented.

Unlike CALL_METHOD, we can not avoid prepending self.

New method signature may be like this:

PyObject_VectorCallMethod(PyObject *name, PyObject **args, Py_ssize_t nargs, PyObject *kwds);

And args[0] is self.  With API like this, we can avoid prepending self.
msg343311 - (view) Author: Michael J. Sullivan (msullivan) * Date: 2019-05-23 16:48
I believe that this is orthogonal to PEP 590.

PyObject_CallMethodObjArgs and friends take varargs which need to be copied into an array one way or another. It is easy (and efficient) to prepend the base while copying the function arguments into the array (see the attached PR). I don't think that vector call will change anything about this.
msg343535 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-05-26 07:23
New changeset 47dd2f9fd86c32a79e77fef1fbb1ce25dc929de6 by Inada Naoki (Michael J. Sullivan) in branch 'master':
bpo-37017: PyObject_CallMethodObjArgs uses LOAD_METHOD optimization (GH-13516)
https://github.com/python/cpython/commit/47dd2f9fd86c32a79e77fef1fbb1ce25dc929de6
History
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81198
2019-05-26 07:23:47methanesetmessages: + msg343535
2019-05-26 07:23:47methanesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-05-23 16:48:57msullivansetmessages: + msg343311
2019-05-23 12:16:56methanesetnosy: + methane
messages: + msg343290
2019-05-23 00:37:21msullivansetnosy: + brett.cannon, vstinner, serhiy.storchaka, yselivanov
2019-05-23 00:36:03msullivansetkeywords: + patch
stage: patch review
pull_requests: + pull_request13433
2019-05-23 00:32:24msullivancreate