GeezerVison is showing github.com — gh-126868: Add freelist for compact ints to _PyLong_New by eendebakpt · Pull Request #128181 · python/cpython
Conversation
eendebakpt
commented
Dec 22, 2024
•
edited by bedevere-app
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
We add freelist support to _PyLong_New (this was missed/left out in #126868). On the pyperformance suite this increases the percentage of allocations from freelist by roughly 1%. For comparison, the addition of the freelist to _PyLong_FromMedium increased the percentage by roughly 20%. Also note that _PyLong_New is used in the new PyLongWriter_Create (see https://peps.python.org/pep-0757/), so usage with external packages might be a bit higher.
Microbenchmark:
import pyperf
def bench_lshift(loops):
range_it = range(loops)
t0 = pyperf.perf_counter()
for ii in range_it:
_ = ii << 2
return pyperf.perf_counter() - t0
if __name__ == "__main__":
runner = pyperf.Runner()
runner.bench_time_func("bench_lshift", bench_lshift)
results in:
Mean +- std dev: [main] 44.7 ns +- 3.0 ns -> [pr] 40.9 ns +- 2.3 ns: 1.09x faster
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
eendebakpt
changed the title
gh-26868: Add freelist for compact ints to _PyLong_New
gh-126868: Add freelist for compact ints to _PyLong_New
Dec 22, 2024
Uh oh!
There was an error while loading. Please reload this page.
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.