Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-121562: optimized hex_from_char#121563

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mdickinson merged 4 commits intopython:mainfromLimaBD:hex-from-char-performance
Jul 14, 2024

Conversation

@LimaBD
Copy link
Contributor

@LimaBDLimaBD commentedJul 10, 2024
edited by bedevere-appbot
Loading

Optimized hex_from_char performance

issue#121562

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

If we measurehex_from_char directly, probably we will get a much better % improvement because there is additional calls thatfloat.fromhex makes apart from this one.

Copy link
Member

@mdickinsonmdickinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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).

erlend-aasland and LimaBD reacted with thumbs up emoji
@LimaBD
Copy link
ContributorAuthor

Hello@mdickinson, thanks for your time, I just added the comment clarifying it but my English is average, anything let me know!

Copy link
Member

@mdickinsonmdickinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for the update; the comment looks good.

LimaBD reacted with heart emoji
@mdickinsonmdickinson merged commit04130b2 intopython:mainJul 14, 2024
@mdickinson
Copy link
Member

@LimaBD Merged. Thank you for the contribution!

LimaBD reacted with heart emoji

@LimaBDLimaBD deleted the hex-from-char-performance branchJuly 14, 2024 12:35
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
Performance improvement to `float.fromhex`: use a lookup tablefor computing the hexadecimal value of a character, in place of theprevious switch-case construct. Patch by Bruno Lima.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@mdickinsonmdickinsonmdickinson approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@LimaBD@mdickinson

[8]ページ先頭

©2009-2025 Movatter.jp