Lazily import `traceback` in `logging`
未关闭
还没有人认领这个 Issue。
performance
stdlib
topic-lazy-imports
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Feature or enhancement
Proposal:
Currently, Lib/logging/__init__.py and Lib/logging/config.py eagerly import traceback, despite it only being used during exception handling. Making this import lazy avoids unnecessary startup overhead and improves initial loading time.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
- gh-150073
| Before 41ms |
After 28ms(~31% faster) |
|---|
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Lib/logging/init.py 和 Lib/logging/config.py 开始,这两个文件目前会 eager 导入 traceback。检查使用它的异常处理路径,并确认只有在需要时才导入 traceback。确认启动时加载方面的改进,并在认为更改完成之前运行相关的 logging 测试。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- performance
- Issue 类型
- 功能
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100