Repository navigation
Conversation
Move bool.__new__ to Argument Clinic with @vectorcall, dropping the hand-written bool_new and bool_vectorcall. The generated vectorcall name matches the hand-written one so the tp_vectorcall slot is unchanged, and argument error messages are unchanged on both paths. pyperf microbenchmark (PGO+LTO, run serially), no significant change on the vectorcall path: | Benchmark | base | bool | |----------------|:-------:|:---------------------:| | bool.__new__ | 23.0 ns | 21.7 ns: 1.06x faster | | bool() | 10.1 ns | 10.4 ns: 1.03x slower | | bool(int) | 12.2 ns | 12.6 ns: 1.03x slower | | bool(True) | 11.1 ns | 11.4 ns: 1.03x slower | | Geometric mean | (ref) | 1.00x slower | Benchmark hidden because not significant (2): bool(__bool__), bool(list) Instructions per call (callgrind, inclusive of bool_vectorcall or bool_new, PGO+LTO): | Case | base | bool | delta | |-----------------------|-----:|-----:|------:| | bool() | 17 | 18 | +1 | | bool(True) | 20 | 23 | +3 | | bool(12345) | 53 | 49 | -4 | | bool([1]) | 50 | 47 | -3 | | bool.__new__(bool, 1) | 127 | 69 | -58 | The compiler folds PyObject_IsTrue(Py_False) for bool(), so the default costs nothing; the small deltas are register allocation. bool.__new__ drops PyArg_UnpackTuple for inline clinic parsing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eendebakpt
approved these changes
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Move
bool.__new__to Argument Clinic with@vectorcall, dropping the hand-writtenbool_newandbool_vectorcall. The generated vectorcall name matches the hand-written one so thetp_vectorcallslot is unchanged, and argument error messages are unchanged on both paths.pyperf microbenchmark (PGO+LTO, run serially), no significant change on the vectorcall path:
bool.__new__Benchmark hidden because not significant (2): bool(bool), bool(list)
Instructions per call (callgrind, inclusive of bool_vectorcall or bool_new, PGO+LTO):
bool.__new__(bool, 1)