Add checking if both strings are the same in `SequenceMatcher.find_longest_match`
未關閉
還沒有人認領這個 Issue。
performance
stdlib
type-feature
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Feature or enhancement
Proposal:
Add checking if sequences a[alo:ahi] and b[blo:bhi] are the same on the beginning of the method find_longest_match in SequenceMatcher. For identical sequences there is no reason to run whole logic when simple check can be done. It appears to fix issue when comparing two slightly different strings ends up with waiting forever for the result. This solves problem reported here https://github.com/pytest-dev/pytest/issues/8998
Proposed fix:
if a[alo:ahi] == b[blo:bhi]:
return Match(alo, blo, len(a[alo:ahi]))
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
- gh-132167
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 SequenceMatcher.find_longest_match 開始,檢查它如何處理要求的序列比較。查看連結的 pytest 報告中關於卡住行為的內容,然後為相同字串和略有不同的字串新增針對性的覆蓋;完成標準是最佳化能夠正常運作,同時不改變傳回的 match。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 功能
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100