Python bytecode compatibility between interpreter versions

Roger Binns rogerb at rogerbinns.com
Sat Mar 20 15:05:03 EST 2004


> Right.  I am aware that freezing is the optimal way to distribute
> apps written in Python today.  After trying out Java though, I have
> to say I'm impressed with the way you can take a bunch of class
> files archived in the exact same jarfile to *ANY* computer with a
> JRE installed, type in java -jar jarfile and have it run _identically_.

Modulo other dependencies also being installed as well.

You can do the same thing with Python.  Just package up the source
files as a zip.

   $ PYTHONPATH=example.zip python main.py

You are considering Python .pyc files and Java class files to be
the same thing.  They aren't.  pyc files are a behind the scenes
implementation detail of one version of the Python interpreter
that are automatically generated and maintained.

Java class files are how you distribute a collection of Java code.
A zip of Python source files is how you distribute Python code
(you can also do it more formally as packages, installers etc).

Roger





More information about the Python-list mailing list