Speed up import rlcompleter by deferring inspect and re
未关闭
还没有人认领这个 Issue。
performance
stdlib
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
rlcompleter imports inspect and re at module scope, but neither is needed to import the module or to construct a Completer. Each is used in exactly one completion method:
inspect: only inCompleter._callable_postfixre: only inCompleter.attr_matches
inspect in particular is a heavy import: it transitively pulls in dis, tokenize, and more. Because rlcompleter is imported during interactive startup (to set up tab completion via readline), this import cost is paid on every interactive session and every import rlcompleter, even though the completion methods may never run.
Linked PRs
- gh-156364
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 rlcompleter 模块以及 issue 中提到的 Completer._callable_postfix 和 Completer.attr_matches 入口点开始。验证更改前后的导入行为,并确认即使导入 rlcompleter 不再为未使用的依赖项付出代价,补全行为仍然正确。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- cli, developer-experience
- Issue 类型
- 重构
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100