Python bytecode compatibility between interpreter versions
rogerb at rogerbinns.com
Mon Mar 22 08:25:12 CET 2004
> So we can't even count on the fact that Python 2.2 running under Windows
> on an Athlon will generate a .pyc file that's identical with that
> generated by the exact same version (2.2) of the interpreter running
> under Linux on, say, a Pentium III, and further, is not even *guaranteed*
> to run on it?!?
There are no guarantees that the same .pyc files will work the next day
with the same interpretter. The interpretter could change the format
every single day if the implementor so wanted.
> This does not seem to fit in with what I've been reading... it would
> be a lot more logical (and convenient) if we can count on .pyc portability
> across different _patch versions_ (.x.y) of the same minor version (.x)
> of CPython on whatever platform it is running on,
Now in practise the .pyc files are not changed every day because there
is no need, but an implementation is free to do so. In many cases they
are the same between platforms and minor versions, but that is not
a specification or a requirement.
> and I believe that
> Python's contributors would make an effort to ensure that this is the case.
Why? To distribute executable Python code, you distribute the .py files.
To distribute executable Java code, you distribute .class files. They
can be wrapped up in .zip and .jar archives respectively.
Java is defined as a compiled language. Python is not a compiled
language, although an implementation is free to do so. If you really
really want a compiled form of Python, try Jython which compiles to
Java .class files.
More information about the Python-list