gh-121562: optimized hex_from_char#121563
Merged
mdickinson merged 4 commits intopython:mainfrom Jul 14, 2024
Merged
Conversation
mdickinson
approved these changes
Jul 10, 2024
Member
mdickinson
left a comment
There was a problem hiding this comment.
LGTM in principle. The old code is agnostic to character encoding (works equally well with ASCII / EBCDIC / whatever), while the new code is based on the bytes of the UTF8-encoded string. That's fine, since the only use-case is applying this to a UTF-8-encoded value. But please could we add a comment that makes it clear that this table should only be used with encodings whose lower half is ASCII (like UTF-8).
Contributor
Author
|
Hello @mdickinson, thanks for your time, I just added the comment clarifying it but my English is average, anything let me know! |
mdickinson
approved these changes
Jul 14, 2024
Member
mdickinson
left a comment
There was a problem hiding this comment.
Thanks for the update; the comment looks good.
Member
|
@LimaBD Merged. Thank you for the contribution! |
estyxx
pushed a commit
to estyxx/cpython
that referenced
this pull request
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.
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.
Optimized hex_from_char performance
issue #121562
Timing with old hex_from_char:
With new hex_from_char:
If we measure
hex_from_chardirectly, probably we will get a much better % improvement because there is additional calls thatfloat.fromhexmakes apart from this one.