Title: zipimport should not check pyc timestamps against zipped py files
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.8, Python 3.7, Python 3.6
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Elvis.Pranskevichus, brett.cannon, eric.snow, gregory.p.smith, ncoghlan, serhiy.storchaka, superluser
Priority: low Keywords: patch

Created on 2015-03-21 18:59 by gregory.p.smith, last changed 2018-11-14 00:54 by gregory.p.smith. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 10327 Elvis.Pranskevichus, 2018-11-05 14:00
Messages (4)
msg238824 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2015-03-21 18:59
The zipimport module checks the timestamp of a pyc file loaded from the zip file against the timestamp of a corresponding py file in the zip if any.  This seems pointless.  By the time someone has created a zip file for zipimport they should have guaranteed that the pyc's are fresh or not have put them into the zip file at all (wasteful).

There is a comment in the code alluding to this, but the mtime check is still done right above.
msg325730 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-19 07:54
zipimport has been rewritten in pure Python (issue25711).
msg329316 - (view) Author: Elvis Pranskevichus (Elvis.Pranskevichus) * (Python triager) Date: 2018-11-05 19:56
I don't think that breaking the .pyc contract by assumption is a good thing.  The desired behavior of never checking the .pyc freshness can be achieved by using unchecked hash-based compilation, or using hash-based compilation and --check-hash-based-pycs=never.  Perhaps we can go further and add a --check-timestamp-based-pycs=never, but IMO, this should be explicit in all cases, including zipimport.
msg329877 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2018-11-14 00:54
Correct, this issue was filed before we had the new pyc options (which came out of our September core dev. sprint in 2016 iirc).

I'll just close it, the way forward for people using zip files on modern CPython interpreters is to explicitly use the new unchecked feature.
Date User Action Args
2018-11-14 00:54:49gregory.p.smithsetstatus: open -> closed
versions: + Python 3.7, Python 3.8
messages: + msg329877

resolution: out of date
stage: patch review -> resolved
2018-11-05 19:56:30Elvis.Pranskevichussetnosy: + Elvis.Pranskevichus
messages: + msg329316
2018-11-05 14:00:30Elvis.Pranskevichussetkeywords: + patch
stage: patch review
pull_requests: + pull_request9638
2018-09-19 07:54:42serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg325730
2015-08-05 15:52:03eric.snowsetnosy: + brett.cannon, ncoghlan, eric.snow, superluser

versions: + Python 3.6, - Python 3.5
2015-03-21 18:59:07gregory.p.smithcreate