views:

19

answers:

1

Is it possible and safe to load pyc files made with a different minor version of python?
For instance 2.5.1 with 2.5.5?

My guess is that the magic number does not change with minor versions.
If I refer to this file import.c the magic number corresponds to the variable pyc_magic ( equals MAGIC or MAGIC+1 )

The file comments say:

Magic word to reject .pyc files generated by other Python versions. It should change for each incompatible change to the bytecode.

I don't see different number for python minor versions, but can we assume it won't change in the future?

A: 

You can't assume that it won't change. Whenever I've needed to distribute .pyc files instead of readable .py files, I've ended up shipping a Python binary too.

Graham Lee