Re-benchmark num_digits_fast against num_digits_faster after the boundary fix
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- python
- 领域
- performance
调研方向
阅读 maths/number_of_digits.py 并比较三个实现,然后在 PR #15761 合并后运行 benchmark()。记录结果,并相应更新 docstring 或函数命名,包括文档中说明的整数转字符串位数限制;当基准测试和说明反映出测得的权衡时,任务即告完成。
由索引模型根据 Issue 内容生成。
描述
Feature description
Feature description
PR #15761 (fixing #15754) makes num_digits_fast in maths/number_of_digits.py exact by adding a correction step after math.log10. The correction computes 10 ** (digits - 1) and 10**digits, which are big-integer powers and add cost for large inputs.
In a quick local timing on 2**100 (200,000 calls with timeit), the corrected approach took about 0.148 s, versus about 0.035 s for len(str(abs(n))). So the function named "fast" may no longer be the fastest of the three.
Proposed follow-up, once #15761 is merged:
- Re-run
benchmark()in the file and record the results for all three functions. - If
num_digits_fastis no longer faster, update its docstring to say it is a log10-based approach, or rename or reorder the functions so the names match the results. - Add a note on the int-to-string length limit:
len(str(n))raises ValueError for ints above about 4300 digits by default in Python 3.11+, while the log10 approach avoids it. That is a reason to keep it.
I'm happy to open a PR for the docstring and benchmark update after #15761 lands.
- 主要语言
- Python
- 星标
- 226k
- 派生
- 51.3k
- 平均合并
- 8 小时 58 分钟
- 30 天内合并 PR
- 4
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TheAlgorithms/Python 的其他 Issue
-
binomial_distribution overflows at 171 trials even when the result is representable可能已有人在做 @landfvit 于 19 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
TheAlgorithms/Python#15656 · 3 条评论 ·
维护者通常 1 天内回复
-
continued_fraction uses float division, producing invalid terms for large integers and raising OverflowError可能已有人在做 @trleo 于 19 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
TheAlgorithms/Python#15655 · 2 条评论 ·
维护者通常 1 天内回复
-
ciphers/base32.py and ciphers/base85.py encode Unicode code points instead of bytes: output diverges from the spec for non-ASCII, round-trips corrupt chars >= U+0400, arbitrary bytes crash可能已有人在做 @Nate-br 于 21 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
TheAlgorithms/Python#15636 · 1 条评论 ·
维护者通常 1 天内回复
-
ciphers/des_ecb.py: encrypt/decrypt silently corrupts any character above U+00FF (round-trip fails)可能已有人在做 @mohammedanasnakhuda 于 21 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
TheAlgorithms/Python#15634 ·
维护者通常 1 天内回复
-
other/password.py: alternative_password_generator ignores the requested length when the required characters exceed it可能已有人在做 @raaj-2222 于 22 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
TheAlgorithms/Python#15633 · 1 条评论 ·
维护者通常 1 天内回复
查看 TheAlgorithms/Python 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 85/100
521xueweihan/HelloGitHub#4385 ·
-
🐛 bug
难度 2/5 1-3 小时 新手友好度 72/100
pdm-project/pdm#4012 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
pollen-robotics/reachy_mini_conversation_app#611 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 91/100
aws-samples/sample-per-model-bedrock#913 ·
维护者通常 1 天内回复
-
lesson-submission pending-review
难度 1/5 1 小时以内 新手友好度 72/100
Ikalus1988/MisakaNet#5115 ·
维护者通常 1 天内回复