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 天內回覆