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

Simplify Capitalize Function #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

Conversation

Copy link
Contributor

@Miladkhoshdel Miladkhoshdel commented Aug 4, 2025

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 (×ばつ faster in benchmarks)
  • More efficient implementation
  • Maintains readability and correctness

Checklist:

  • Code compiles without errors
  • Performance verified with benchmarks

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Aug 24, 2025
@MaximSmolskiy MaximSmolskiy changed the title (削除) Simplify Capitalize Function Using ASCII Arithmetic for 5x Performance Boost (削除ここまで) (追記) Simplify Capitalize Function (追記ここまで) Aug 24, 2025
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Aug 24, 2025
@MaximSmolskiy MaximSmolskiy merged commit a8c5616 into TheAlgorithms:master Aug 24, 2025
5 checks passed
cclauss pushed a commit to cclauss/Python that referenced this pull request Aug 25, 2025
* Simplify the capitalize function using ASCII arithmetic to make the algorithm five times faster.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update capitalize.py
* Update capitalize.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@MaximSmolskiy MaximSmolskiy MaximSmolskiy approved these changes

+1 more reviewer

@mindaugl mindaugl mindaugl 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.

AltStyle によって変換されたページ (->オリジナル) /