Skip to content

[mypyc] feat: stararg fastpath when calling fn(*args) with tuple #19623

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 8 commits into from
Aug 13, 2025

Conversation

BobTheBuidler
Copy link
Contributor

@BobTheBuidler BobTheBuidler commented Aug 9, 2025

There are 3 safe cases where we can reuse a tuple when calling a python function:
fn(*args)
fn(*args, **kwargs)
fn(*args, k=1, k2=2, **kwargs)

This PR covers the first two cases.

The IR diff will probably demonstrate this change better than I can explain it.

@BobTheBuidler
Copy link
Contributor Author

@JukkaL @ilevkivskyi I notice other people are somehow Requesting Review for other PRs via the Github UI. I couldn't figure out how to do that but this PR is nice and short, and ready for review.

@BobTheBuidler BobTheBuidler changed the title [mypyc] feat: reuse existing tuple when calling fn(*args) [mypyc] feat: stararg fastpath when calling fn(*args) with tuple Aug 9, 2025
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Nice win! Constructing objects is slow so this should help (didn't benchmark though).

@JukkaL JukkaL merged commit fb41108 into python:master Aug 13, 2025
13 checks passed
@BobTheBuidler
Copy link
Contributor Author

Yeah I also didn't think to do any benchmarking here since the IR shows such a clear improvement. Thanks for merging, I'll rebase those other 3 related PRs for you sometime today.

@BobTheBuidler BobTheBuidler deleted the tupe branch August 13, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants