This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brett.cannon
Recipients brett.cannon, eric.snow, ncoghlan
Date 2016-01-07.17:52:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1452189141.27.0.112439951883.issue26042@psf.upfronthosting.co.za>
In-reply-to
Content
The reason the magic number exists in .pyc files is because back in Python 2 we only had a single .pyc file per module, which meant if you suddenly switched versions of Python you needed a way to know that the .pyc file was wrong for the running version of Python.

This is not the case in Python 3. Thanks to __pycache__ directories we have separate .pyc files per release version of Python (we also have .pyc files for each optimization level of Python). If we changed the sys.implementation.cache_tag to include the bugfix version -- and maybe even release level -- then the magic number wouldn't be necessary for users. It does make developing bytecode a little bit more difficult for core developers since they will have to clear out their .pyc files during development, but users wouldn't be affected.

Now I don't know if this is really worth the simplification it provides. I don't think it's worth the compatibility break for any code that may be reading .pyc files and I doubt there is any measurable performance benefit.  But the realization struck me and I figured I should at least write it down in case anyone else thinks of it.
History
Date User Action Args
2016-01-07 17:52:21brett.cannonsetrecipients: + brett.cannon, ncoghlan, eric.snow
2016-01-07 17:52:21brett.cannonsetmessageid: <1452189141.27.0.112439951883.issue26042@psf.upfronthosting.co.za>
2016-01-07 17:52:21brett.cannonlinkissue26042 messages
2016-01-07 17:52:20brett.cannoncreate