GeezerVison is showing github.com — gh-87613: Use AC vectorcall for float by cmaloney · Pull Request #158201 · python/cpython
Conversation
cmaloney
commented
Sep 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Move float.__new__ to AC vectorcall dropping the hand-written.
Running microbenchmark from the original add (pyperf timeit "float(0)" in gh-86039) shows no significant performance change.
The generated name matches the hand-written name so the tp_vectorcall slot is unchanged.
Update the vectorcall slot parity test to include float.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Move float.__new__ to AC vectorcall dropping the hand-written.
Running microbenchmark from the original add (`pyperf timeit "float(0)"`
in pythongh-86039) shows no significant performance change.
The generated name matches the hand-written name so the tp_vectorcall
slot is unchanged.
Update the vectorcall slot-parity test to include float.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Changes look good to me. On a local build the new code did not have a tail call, while current main did (MSVC compiler). I used Claude to let the argument clinic generate slightly easier code to compile. A godbolt link that compares main, this PR and the branch linked above: https://godbolt.org/z/5WodhW3nb
| variant |
compiler |
instructions |
saved regs |
frame (bytes) |
tail-call to impl |
| main |
MSVC 19.4x /O2 |
47 |
3 |
32 |
yes |
| PR 158201 |
MSVC 19.4x /O2 |
45 |
4 |
40 |
yes |
| branch |
MSVC 19.4x /O2 |
41 |
3 |
32 |
yes |
| main |
GCC 15.2 -O2 |
34 |
3 |
0 |
yes |
| PR 158201 |
GCC 15.2 -O2 |
34 |
3 |
0 |
yes |
| branch |
GCC 15.2 -O2 |
34 |
3 |
0 |
yes |
| main |
Clang 20.1 -O2 |
36 |
3 |
0 |
yes |
| PR 158201 |
Clang 20.1 -O2 |
36 |
3 |
0 |
yes |
| branch |
Clang 20.1 -O2 |
36 |
3 |
0 |
yes |
These changes are minor though (and compiler dependent, one could argue MSCV just needs to do a better job), so I am fine with merging this as is.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
cmaloney
commented
Sep 27, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Appreciate the numbers. Lines up with some of what I've been finding: A lot of Argument Clinic binding performance is in compiler inlining and optimization.
I've been working on getting str, list, and int to be able to use AC Vectorcall and they are all slower because the hand written manually inlines important cases. Compilers see "two callers" + "too much complexity" and don't do the inlining most the time. AC doesn't know there is something it could inline (ex. here's how to get the global constant empty bytes for zero-arg, here's the one-arg from type A, etc.). Have some ideas on how to help AC have that information and be able to provide more type-specific overloads for the JIT as well potentially... but very prototype.
Hoping as keep iterating on AC will get some large systemic improvements. AC Vectorcall is faster when there are keyword args but often slower for positional arguments in conversions currently. When there wasn't a Vectorcall before things speedup especially if can unlock additional optimizations. Speedup depends on how much overhead the arg conversion was.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
# Conflicts:
# Objects/clinic/floatobject.c.h
cmaloney
changed the title
gh-87613: Use the AC vectorcall for float
gh-87613: Use AC vectorcall for float
Oct 5, 2026
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
erlend-aasland
Awaiting requested review from erlend-aasland
erlend-aasland is a code owner
AA-Turner
Awaiting requested review from AA-Turner
AA-Turner is a code owner
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|