Speed up array appends
維護者通常 2 天內回覆
評估
研究方向
Start from the array append path that tomlkit.dumps reaches when a Python list is converted, and find where the index is rebuilt for every existing item. Time the 3000-item example before changing anything. Done means that a normal append only indexes the new item, middle inserts and special formatting items still rebuild, and the output text and existing tests stay the same.
由索引模型根據 Issue 內容生成。
描述
Adding an item to the end of an array rebuilds the index for every item already in it. So when an array is built one item at a time, the same entries get checked over and over.
This also happens when writing a Python list with tomlkit.dumps, not just when calling append directly. It can add up when writing a long file list or dependency list.
For example, this goes through the repeated append path:
import tomlkit
files = [f"src/package/module_{n}.py" for n in range(3000)]
text = tomlkit.dumps({"files": files})
For a normal append, the old items haven't moved. Could we keep their indexes and add only the new one? Middle inserts and the special formatting items can keep the current rebuild.
For N normal appends, that would bring the index work from O(N²) to O(N), without adding another cache. Converting the values and writing the TOML would still take their own time.
- 主要語言
- Python
- 星號
- 864
- 分支
- 207
- 平均合併
- 3 天 23 小時
- 30 天內合併 PR
- 25
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python-poetry/tomlkit 的其他 Issue
-
Emptying a nested array of tables before an out-of-order super-table renders invalid TOML (0.15.2, since #567)可能已有人在做 @ryanchou1994 今天認領。 未關閉
難度 4/5 3-5 天 新手友好度 45/100
python-poetry/tomlkit#690 · 1 則留言 ·
維護者通常 2 天內回覆
-
`update()` on an out-of-order table raises `IndexError` after a sub-table fragment was popped可能已有人在做 @rajmodi8905 於 11 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 68/100
python-poetry/tomlkit#675 · 3 則留言 ·
維護者通常 2 天內回覆
-
Deleting the last key under a dotted key in an inline table produces invalid TOML可能已有人在做 @cig13zs 於 17 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 62/100
python-poetry/tomlkit#662 ·
維護者通常 2 天內回覆
-
AttributeError on an out-of-order table under an indented header (4+ levels)可能已有人在做 @cig13zs 於 17 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 18/100
python-poetry/tomlkit#661 ·
維護者通常 2 天內回覆
-
In-place array repetition changes values without updating serialized TOML可能已有人在做 @harbinresearcher 於 21 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 35/100
python-poetry/tomlkit#646 · 1 則留言 ·
維護者通常 2 天內回覆
查看 python-poetry/tomlkit 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
pytest-dev/pyfakefs#1367 · 1 則留言 ·
維護者通常 2 天內回覆
-
IFEvalG exclude_word_harder misses the keyword next to punctuation, at the start or end of the text, and in other letter case可能已有人在做 @damienen 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
allenai/open-instruct#2151 ·
維護者通常 1 天內回覆
-
feat(plan): support convertorLabels and convertorAffinity in Plan resource可能已有人在做 @AmenB 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
RedHatQE/openshift-python-wrapper#2849 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 25 天內回覆
-
難度 2/5 1-3 小時 新手友好度 70/100
libnativeapi/nativeapi#21 ·