-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Add Py_TuplePack2 and Py_TuplePack1 #118222
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
Comments
How large is the difference between I afraid that it is a preliminary optimization. We need new API if:
|
@serhiy-storchaka Thanks for the response. I agree the need for a new API seems slim. The only reason would be performance. Here are some results: with the benchmark script from https://discuss.python.org/t/nwise-itertools/51718/17 we can compare the performance of the cpython Main:
With
So using I will keep this issue open a few more days to see if there are different opinions or more use cases where the performance difference is important. If not I will close the issue and (perhaps) make a PR to update just the |
Feature or enhancement
Proposal:
In the cpython codebase
PyTuple_Pack
is used at various places (https://github.com/search?q=repo%3Apython%2Fcpython+PyTuple_Pack&type=code). The execution is not very fast as the implementation usesva_arg
internally. For the 1- and 2 argument case we can improve performance by providing a direct implementation.Using
PyTuple_Pack2
(example implementation main...eendebakpt:cpython:putuple_pack2) performance of components likepairwise
can be improved. See https://discuss.python.org/t/nwise-itertools/51718/22Py_TuplePack1
andPy_TuplePack2
to the cpython interface? If so, should it be in the public or private API.Py_TuplePack2
should we use it at all places applicable, or only the few performance critical ones?Py_TuplePack1
that already exists is the internal_PyTuple_FromArray
with second argument1
.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered: