You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2019-08-21.16:17:42.453>labels= ['interpreter-core', '3.9', 'performance']
title='speed-up PyLong_As*() for large longs'updated_at=<Date2022-03-15.07:54:07.512>user='https://github.com/sir-sigurd'
The mentioned pattern is also used in PyLong_AsLongLongAndOverflow(), but I left it untouched since the proposed change doesn't seem to affect its performance.
Revisiting this 2+ year-old bug report, can I create another PR that implements the old PR's comments' suggestions?
thatbirdguythatuknownot commented on Mar 14, 2022
thatbirdguythatuknownotmannequin
Mannequin
More actions
New benchmarks with the new changes:
PyLong_AsSsize_t: Mean +- std dev: [orig] 10.3 us +- 0.6 us -> [modif] 9.03 us +- 0.61 us: 1.14x faster
PyLong_AsSize_t: Mean +- std dev: [orig] 10.5 us +- 2.4 us -> [modif] 9.26 us +- 0.17 us: 1.13x faster
PyLong_AsLong: Mean +- std dev: [orig] 12.7 us +- 0.1 us -> [modif] 11.2 us +- 0.4 us: 1.14x faster
PyLong_AsUnsignedLong: Mean +- std dev: [orig] 12.5 us +- 0.4 us -> [modif] 11.4 us +- 0.6 us: 1.10x faster
Benchmark hidden because not significant (2): PyLong_AsLongLong, PyLong_AsUnsignedLongLong
Activity
sir-sigurd commentedon Aug 21, 2019
PyLong_As*() functions computes result for large longs like this:
It can be rewritten like this:
This provides some speed-up:
The mentioned pattern is also used in PyLong_AsLongLongAndOverflow(), but I left it untouched since the proposed change doesn't seem to affect its performance.
thatbirdguythatuknownot commentedon Mar 14, 2022
Revisiting this 2+ year-old bug report, can I create another PR that implements the old PR's comments' suggestions?
thatbirdguythatuknownot commentedon Mar 14, 2022
New benchmarks with the new changes:
PyLong_AsSsize_t: Mean +- std dev: [orig] 10.3 us +- 0.6 us -> [modif] 9.03 us +- 0.61 us: 1.14x faster
PyLong_AsSize_t: Mean +- std dev: [orig] 10.5 us +- 2.4 us -> [modif] 9.26 us +- 0.17 us: 1.13x faster
PyLong_AsLong: Mean +- std dev: [orig] 12.7 us +- 0.1 us -> [modif] 11.2 us +- 0.4 us: 1.14x faster
PyLong_AsUnsignedLong: Mean +- std dev: [orig] 12.5 us +- 0.4 us -> [modif] 11.4 us +- 0.6 us: 1.10x faster
Benchmark hidden because not significant (2): PyLong_AsLongLong, PyLong_AsUnsignedLongLong
Geometric mean: 1.09x faster
thatbirdguythatuknownot commentedon Apr 10, 2022
Is this issue still supposed to be open?
gh-82088: Improve performance of PyLong_As*() for multi-digit ints (#…
pythongh-82088: Improve performance of PyLong_As*() for multi-digit i…
pythongh-82088: Improve performance of PyLong_As*() for multi-digit i…
pythongh-82088: Improve performance of PyLong_As*() for multi-digit i…
pythongh-82088: Improve performance of PyLong_As*() for multi-digit i…
pythongh-82088: Improve performance of PyLong_As*() for multi-digit i…
StanFromIreland commentedon Oct 4, 2025
cc @eendebakpt @vstinner
Triage: Can this be closed?
picnixz commentedon Oct 5, 2025
There's nothing more to do for now.