compileall shouldn't recompile up-to-date files with hash-based invalidation mode
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Feature or enhancement
Proposal:
When you compile sources into .pyc files with python -m compileall while using the defaul invalidation mode (timestamp), the script verifies whether the compilation is necessary (the pyc file is up to date) and can skip it:
$> python -m compileall --invalidation-mode=timestamp script.py
Compiling 'script.py'...
$> python -m compileall --invalidation-mode=timestamp script.py
$> # the compilation is skipped
When either of the hash invalidation modes is used instead, this doesn't work - the hash based check is not there. https://github.com/python/cpython/blob/main/Lib/compileall.py#L229
$> python -m compileall --invalidation-mode=checked-hash script.py
Compiling 'script.py'...
$> python -m compileall --invalidation-mode=checked-hash script.py
Compiling 'script.py'...
$>
I think it would make sense to add the same functionality for the other two invalidation modes as well?
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
- gh-121960
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Lib/compileall.py 中链接行附近的失效模式处理开始,并使用针对 checked-hash 和 unchecked-hash 模式所示的两个 python -m compileall 命令重现该行为。当对于这两种哈希失效模式,重复编译最新的源文件都会被跳过,同时保留现有的时间戳行为时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- cli
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100