[Python-Dev] importing .pyc-files generated by Python 1.5.2 in Python 1.6. Why not?

Fred L. Drake fdrake@acm.org
Tue, 23 May 2000 07:47:52 -0700 (PDT)

On Tue, 23 May 2000, Peter Funk wrote:
 > Python 1.6 reports a bad magic error, when someone tries to import a .pyc
 > file compiled by Python 1.5.2.  AFAIK only new features have been
 > added.  So why it isn't possible to use these old files in Python 1.6?

  In theory, perhaps it could; I don't know if the extra work is worth it,
  What's happening is that the .pyc magic number changed because the
marshal format has been extended to support Unicode string objects.  The
old format should still be readable, but there's nothing in the .pyc
loader that supports the acceptance of multiple versions of the marshal
  Is there reason to think that's a substantial problem for users, given
the automatic recompilation of bytecode from source?  The only serious
problems I can see are when multiple versions of the interpreter are being
used on the same collection of source files (because the re-compilation
occurs more often and affects performance), and when *only* .pyc/.pyo
files are available.
  Do you have reason to suspect that either case is sufficiently common to
complicate the .pyc loader, or is there another reason that I've missed
(very possible, I admit)?


Fred L. Drake, Jr.  <fdrake at acm.org>