Refactor: simplify scientific() and extract _SUPERSCRIPT_MAP constant#313
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #313 +/- ##
==========================================
- Coverage 99.56% 99.55% -0.01%
==========================================
Files 12 12
Lines 911 907 -4
==========================================
- Hits 907 903 -4
Misses 4 4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
I've just added benchmarking to the CI, so updated this PR from |
hugovk
reviewed
May 14, 2026
Contributor
Author
|
Thanks for the feedback! I moved _SUPERSCRIPT_MAP after the TYPE_CHECKING block and switched to a list comprehension. Let me know if I should make any other changes! |
scientific() and extract _SUPERSCRIPT_MAP constant
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.


Cool repo! I made a small cleanup to the scientific() function in number.py.
I extracted the exponents dict as a module-level constant so it's not recreated on every function call. I also simplified the character mapping loop into a generator expression.
I'm happy to make any changes if necessary. Hope this helps!