A better JSON check_circular
未關閉
還沒有人認領這個 Issue。
extension-modules
type-refactor
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Feature or enhancement
Proposal:
json.dump(check_circular=True) uses a dictionary to track all objects already visited and creates keys with PyLong_FromVoidPtr. There is another solution for recursive container types in CPython already: Py_ReprEnter and Py_ReprLeave.
I have a patch to replace the dictionary and custom object tracking with the CPython functions and that removes some code and also avoids allocating Long objects for each recursive call.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
- gh-137104
- gh-137286
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先檢視 json.dump(check_circular=True) 和現有的 Py_ReprEnter/Py_ReprLeave 機制,接著檢查已連結的 PR gh-137104 和 gh-137286。當所提出的追蹤方法在移除 dictionary 和每次呼叫的 PyLong_FromVoidPtr allocations 的同時,仍能保留遞迴容器的行為時,即可視為完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c, python
- 領域
- backend
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100