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

PyUnicode_Type needs vectorcall. #117709

Closed
markshannon opened this issue Apr 10, 2024 · 5 comments
Closed

PyUnicode_Type needs vectorcall. #117709

markshannon opened this issue Apr 10, 2024 · 5 comments
Labels
3.13 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@markshannon
Copy link
Member

markshannon commented Apr 10, 2024

Calls to str() must use the old tp_call protocol instead of tp_vectorcall, as PyUnicode_Type does not implement vectorcall.
All other common types, including list, dict, tuple implement vectorcall. For some reason str got overlooked.

Linked PRs

@markshannon markshannon added performance Performance or resource usage interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.13 bugs and security fixes labels Apr 10, 2024
@erlend-aasland
Copy link
Contributor

For some reason str got overlooked.

Perhaps since all three parameters can be passed as both keyword and positional arguments. That's a lot of combinations to spell out.

@erlend-aasland
Copy link
Contributor

I made a PoC branch just for fun: https://github.com/erlend-aasland/cpython/pull/new/perf/unicode-vectorcall

Added paths for the cases where all args are positional, in additional to two positional and one keyword arg, and one positional and encoding & errors as keyword args in that order only. Fallback to tp_call (build dict, etc.) for all other cases.

@erlend-aasland

This comment was marked as outdated.

erlend-aasland added a commit that referenced this issue Apr 11, 2024
…ments (#117746)

Fall back to tp_call() for cases when arguments are passed by name.

Co-authored-by: Donghee Na <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
@erlend-aasland
Copy link
Contributor

Resolved with #117746 which speeds up str() calls with positional-only arguments.

@erlend-aasland
Copy link
Contributor

We should consider "vectorcallising" zip() also.

diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…y arguments (python#117746)

Fall back to tp_call() for cases when arguments are passed by name.

Co-authored-by: Donghee Na <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

2 participants