You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
zipimport should not check pyc timestamps against zipped py files #67922
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2018-11-14.00:54:49.285>created_at=<Date2015-03-21.18:59:07.067>labels= ['extension-modules', '3.8', 'type-feature', '3.7']
title='zipimport should not check pyc timestamps against zipped py files'updated_at=<Date2018-11-14.00:54:49.283>user='https://github.com/gpshead'
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).
zipimport has been rewritten in pure Python (bpo-25711).
elprans commented on Nov 5, 2018
elpransmannequin
Mannequin
More actions
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.
Activity
gpshead commentedon Mar 21, 2015
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).
https://hg.python.org/cpython/file/e8878579eb68/Modules/zipimport.c#l1187
There is a comment in the code alluding to this, but the mtime check is still done right above.
serhiy-storchaka commentedon Sep 19, 2018
zipimport has been rewritten in pure Python (bpo-25711).
elprans commentedon Nov 5, 2018
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.
gpshead commentedon Nov 14, 2018
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.