Improve performance of `find_max_char`
未关闭
还没有人认领这个 Issue。
performance
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在 CPython 中找到 find_max_char 的实现,并使用当前行为运行所提供的 pyperf 命令。将基准测试结果与报告中的 442 ns 参考值和 388 ns 补丁结果进行比较;当精简后的测试方法在不改变字符串创建行为的情况下提升性能时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- performance
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 30/100