| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
How is methodcaller well used? Often converting to the vectorcall requires maintenance cost, so you need to justify increasing the code complexity. |
Sorry, something went wrong.
|
@corona10 The PR indeeds adds some additional code (the methodcaller_vectorcall is small, the initialization code a bit larger), but it is not a lot of code. If maintenance is a concern, I can try rewrite the code to keep the additions to a minimum. (in this PR I added some code because of an earlier concern of added memory usage)
But comparing performance and maintenance costs is a bit like comparing apples and oranges, so it it up to you (and other core devs) to make a decision here. |
Sorry, something went wrong.
| Py_CLEAR(mc->xargs); | ||
| Py_CLEAR(mc->kwds); | ||
| return 0; | ||
| _methodcaller_clear_vectorcall(mc); |
There was a problem hiding this comment.
Why did you separate the function?
Please, just inline the function in here if there is no specific reason.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
I left some minor comments, I will take a look at this PR more.
Sorry, something went wrong.
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
…endebakpt/cpython into fastmethodcaller_lazy_vectorcall
There was a problem hiding this comment.
LGTM
Let's see the result of refleak tests.
Sorry, something went wrong.
|
Leak tests are unrelated to this PR. |
Sorry, something went wrong.
|
Nice optimization. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is a variation on #106960 where the allocation of the structures required for the vectorcall is delayed untill the first invocation of the methodcaller. The advantage is that that for methodcaller objects that are created, but never used, the creation time and amount of memory used is the same as current main.
Benchmark results:
import pyperf setup = """ from operator import methodcaller as mc arr = [] call = mc('sort') call_kwarg = mc('sort', reverse=True) """ runner = pyperf.Runner() runner.timeit(name="call", stmt="call(arr)", setup=setup) runner.timeit(name="creation", stmt="call = mc('sort')", setup=setup) runner.timeit(name="creation+call", stmt="call = mc('sort'); call(arr)", setup=setup) runner.timeit(name="call kwarg", stmt="call_kwarg(arr)", setup=setup) runner.timeit(name="creation kwarg", stmt="call = mc('sort', reverse=True)", setup=setup) runner.timeit(name="creation+call kwarg", stmt="call = mc('sort', reverse=True); call(arr)", setup=setup)