-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hex_from_char run faster replacing switch-case with lookup table #121562
Labels
Comments
LimaBD
added a commit
to LimaBD/cpython
that referenced
this issue
Jul 10, 2024
LimaBD
added a commit
to LimaBD/cpython
that referenced
this issue
Jul 10, 2024
@mdickinson, this code was added by you in 65fe25e (bpo-3008/gh-47258). |
LimaBD
added a commit
to LimaBD/cpython
that referenced
this issue
Jul 10, 2024
mdickinson
pushed a commit
that referenced
this issue
Jul 14, 2024
Performance improvement to `float.fromhex`: use a lookup table for computing the hexadecimal value of a character, in place of the previous switch-case construct. Patch by Bruno Lima.
PR merged! |
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
Performance improvement to `float.fromhex`: use a lookup table for computing the hexadecimal value of a character, in place of the previous switch-case construct. Patch by Bruno Lima.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Feature or enhancement
Proposal:
Replacing switch-case in
hex_from_char
with a lookup table makes pythonfloat.fromhex(...)
run 4%-5% faster. Probably if we measurehex_from_char
in isolation we will get a much greater % improvement.cpython/Objects/floatobject.c
Lines 1145 to 1208 in f621618
New
hex_from_char
code:Timing with old
hex_from_char
:$ ./python -m pyperf timeit --duplicate 100 "float.fromhex('0x123456.ffffp10')" ..................... Mean +- std dev: 86.0 ns +- 0.9 ns
With new
hex_from_char
:./python -m pyperf timeit --duplicate 100 "float.fromhex('0x123456.ffffp10')" ..................... Mean +- std dev: 81.8 ns +- 1.0 ns
I will create a new PR.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: