8000 gh-89013: Improve the performance of methodcaller (lazy version) by eendebakpt · Pull Request #107201 · python/cpython · GitHub
[go: up one dir, main page]

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
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
fix double free
  • Loading branch information
eendebakpt committed Jul 24, 2023
commit f1742565189df2159adbf09f1ab6c09e96b67705
9 changes: 3 additions & 6 deletions Modules/_operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1594,10 +1594,11 @@ static void * _methodcaller_initialize_vectorcall(methodcallerobject* mc)
return (void *)1;
}

static _methodcaller_clear_vectorcall(methodcallerobject* mc)
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);
}
}
Expand Down Expand Up @@ -1668,16 +1669,13 @@ methodcaller_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return (PyObject *)mc;
}

static int
static void
methodcaller_clear(methodcallerobject *mc)
{
Py_CLEAR(mc->name);
Py_CLEAR(mc->xargs);
Py_CLEAR(mc->kwds);

_methodcaller_clear_vectorcall(mc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you separate the function?
Please, just inline the function in here if there is no specific reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it more symmetric with the _methodcaller_initialize_vectorcall. I will inline here. Let me know if the _methodcaller_initialize_vectorcall should also be inlined.


return 0;
}

static void
Expand All @@ -1686,7 +1684,6 @@ methodcaller_dealloc(methodcallerobject *mc)
PyTypeObject *tp = Py_TYPE(mc);
PyObject_GC_UnTrack(mc);
(void)methodcaller_clear(mc);
PyMem_Free(mc->vectorcall_args);
tp->tp_free(mc);
Py_DECREF(tp);
}
Expand Down
0