Skip to content

Simplify Capitalize Function Using ASCII Arithmetic for 5x Performance Boost #12879

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Miladkhoshdel
Copy link

Changes:

  • Removed dependency on string.ascii_lowercase and string.ascii_uppercase and Replaced string-based capitalization with manual ASCII offset
  • Reduced function complexity and branching
  • Added basic unit tests to ensure correctness

Benefits:

  • Eliminated external module dependency (string) for better portability and reduced overhead
  • Improved performance (5× faster in benchmarks)
  • More efficient implementation
  • Maintains readability and correctness

Checklist:

  • Code compiles without errors
  • Performance verified with benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant