GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-87613: Use AC and AC vectorcall for bool by cmaloney · Pull Request #160791 · python/cpython Conversation
|
| 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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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 <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.