Improve performance of `find_max_char`
Open
Nobody has claimed this yet.
performance
type-feature
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Proposal:
find_max_char is called each time a string is created.
By reducing the amount of tests, the performance can be improved considerably.
python -m pyperf timeit -s "b=('a' *1000+ '\u019f'*2)" "b[:-1]"
+-----------+--------+----------------------+
| Benchmark | ref | patch |
+===========+========+======================+
| timeit | 442 ns | 388 ns: 1.14x faster |
+-----------+--------+----------------------+
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
- gh-122902
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the find_max_char implementation in CPython and run the provided pyperf command with the current behavior. Compare the benchmark result against the reported 442 ns reference and 388 ns patch result; done means the reduced testing approach improves performance without changing string creation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100