Skip to content

gh-89013: Improve the performance of methodcaller (lazy version) #107201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
  • Loading branch information
eendebakpt and corona10 authored Jul 30, 2023
commit 1ceea518ef709131c0ff99ef8ef3521f2336a4e6
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Improve performance of ``operator.methodcaller`` by use of the the vectorcall protocol. Patch by Anthony Lee and Pieter Eendebak.
Improve performance of :func:`operator.methodcaller` using the :pep:`590` ``vectorcall`` convention.
Patch by Anthony Lee and Pieter Eendebak.
8 changes: 4 additions & 4 deletions Modules/_operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ typedef struct {
vectorcallfunc vectorcall;
} methodcallerobject;

static void * _methodcaller_initialize_vectorcall(methodcallerobject* mc)
static int _methodcaller_initialize_vectorcall(methodcallerobject* mc)
{
PyObject* args = mc->xargs;
PyObject* kwds = mc->kwds;
Expand Down Expand Up @@ -1599,8 +1599,8 @@ static void _methodcaller_clear_vectorcall(methodcallerobject* mc)
if (mc->vectorcall_args != NULL) {
PyMem_Free(mc->vectorcall_args);
mc->vectorcall_args = 0;
Py_CLEAR(mc->vectorcall_kwnames);
}
Py_CLEAR(mc->vectorcall_kwnames);
}

static PyObject *
Expand Down Expand Up @@ -1632,7 +1632,7 @@ static PyObject *
methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
methodcallerobject *mc;
PyObject* name;
PyObject *name;

if (PyTuple_GET_SIZE(args) < 1) {
PyErr_SetString(PyExc_TypeError, "methodcaller needs at least "
Expand Down Expand Up @@ -1807,7 +1807,7 @@ methodcaller_reduce(methodcallerobject *mc, PyObject *Py_UNUSED(ignored))
if (!mc->kwds || PyDict_GET_SIZE(mc->kwds) == 0) {
Py_ssize_t i;
Py_ssize_t newarg_size = PyTuple_GET_SIZE(mc->xargs);
PyObject * newargs = PyTuple_New(newarg_size);
PyObject *newargs = PyTuple_New(newarg_size);
if (newargs == NULL)
return NULL;
PyTuple_SET_ITEM(newargs, 0, Py_NewRef(mc->name));
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy