[Python-Dev] Identifying magic prefix on Python files?

Guido van Rossum guido@digicool.com
Sun, 04 Feb 2001 16:02:22 -0500


> Python's .pyc files don't have a magic prefix that the file(1) utility
> can recognize.  Would anyone object if I fixed this?  A trivial pair of
> hacks to the compiler and interpreter would do it.  Backward compatibility
> would be easily arranged.

I don't understand.  The .pyc file has a magic number.  Why is this
incompatible with file(1)?

> Embedding the Python version number in the prefix might enable some
> useful behavior down the road.

If we're going to redesign the .pyc file header, I'd propose the
following:

(1) magic number -- for file(1), never to be changed

(2) some kind of version -- Python version, or API version, or
    bytecode version

(3) mtime of .py file

(4) options, e.g. is this a .pyc or a .pyo

(5) size of marshalled code following

(6) marshalled code

--Guido van Rossum (home page: http://www.python.org/~guido/)