Skip to content
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

Don't use Py_BuildValue("(OO...)", a, b, ...) #118379

Closed
nineteendo opened this issue Apr 29, 2024 · 1 comment
Closed

Don't use Py_BuildValue("(OO...)", a, b, ...) #118379

nineteendo opened this issue Apr 29, 2024 · 1 comment
Labels
performance Performance or resource usage type-feature A feature request or enhancement

Comments

@nineteendo
Copy link
Contributor

nineteendo commented Apr 29, 2024

Feature or enhancement

Proposal:

This is an inefficient way to build a tuple:

Py_BuildValue("(OO)", a, b)

This is faster, and more readable:

PyTuple_Pack(2, a, b)

And if #118222 lands, we could use this even faster variant for length 1 & 2:

PyTuple_Pack2( a, b)

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

@nineteendo nineteendo added the type-feature A feature request or enhancement label Apr 29, 2024
@erlend-aasland erlend-aasland added the performance Performance or resource usage label Apr 29, 2024
@serhiy-storchaka
Copy link
Member

I already did something similar recently: #110093.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants