New submission from Brett Cannon:
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
Eric Snow added the comment:
That's an interesting thought. My intuition is that it wouldn't be worth doing.
It would certainly trade one development overhead for another, so it's a bit of
a wash there, I think. Are there other spots in the stdlib that rely on the
magic number? Is it used
Serhiy Storchaka added the comment:
What about zipimport? It doesn't use __pycache__ directories, but just try to
read *.pyc file, then *.py file.
The launcher on Windows also check magic number (it contains a mapping from
magic numbers to Python versions).
--
nosy: +serhiy.storchaka
Brett Cannon added the comment:
I figured it was a wash. Closing as "won't fix".
As for zipimport, it's busted thanks to the fact that it doesn't work with
__pycache__ directories. Yet another reason it needs to be rewritten.
--
resolution: -> wont fix
status: open -> closed