python / python/cpython

compileall shouldn't recompile up-to-date files with hash-based invalidation mode

Đang mở
#121,577 6 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

stdlib type-feature
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu trong Lib/compileall.py, tại phần xử lý chế độ invalidation xung quanh dòng được liên kết, và tái hiện hành vi bằng hai lệnh python -m compileall được nêu cho các chế độ checked-hash và unchecked-hash. Hoàn tất khi việc biên dịch lặp lại một mã nguồn đã được cập nhật bị bỏ qua đối với cả hai chế độ invalidation bằng hash, đồng thời giữ nguyên hành vi timestamp hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
cli
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.