python / python/cpython

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

Offen
#121,577 6 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

stdlib type-feature
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne in Lib/compileall.py bei der Behandlung des Invalidation-Modus rund um die verlinkte Zeile und reproduziere das Verhalten mit den beiden für die Modi checked-hash und unchecked-hash gezeigten python -m compileall-Befehlen. Als erledigt gilt, wenn die wiederholte Kompilierung einer aktuellen Quelle für beide Hash-Invalidierungsmodi übersprungen wird und das bestehende Zeitstempelverhalten erhalten bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
cli
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.