Optimize ASCII lowercase conversion performance - #15203
Conversation
3de987a to
74bc163
Compare
cclauss
left a comment
There was a problem hiding this comment.
Please add a benchmark that proves that the proposed changes provide significant runtime improvements.
Thanks for the feedback. I benchmarked both implementations under the same conditions using timeit.repeat(). Benchmark codeResults: Both implementations were tested with the same inputs, iteration counts, and number of repeats. Across the tested input sizes, the proposed implementation shows a consistent median runtime improvement of approximately 27–29%. |
Thanks for the suggestion. I agree that comprehensions are a better fit for this pattern. I followed up on this approach in a separate PR: I also benchmarked the new implementation against the merged append-based implementation. The comprehension-based version is consistently faster, showing around 9–13% median improvement across different input sizes. |
Describe your change:
Improve the performance of the existing ASCII lowercase conversion by replacing the generator expression with an explicit loop.
The updated implementation:
Benchmark using:
Results on my machine:
Checklist: