[Python-Dev] Proposal: .pyc file format change

Christian Tismer tismer@tismer.com
Sun, 28 May 2000 17:02:41 +0200


"M.-A. Lemburg" wrote:
> 
> Peter Funk wrote:
> >
> > [M.-A. Lemburg]:
> > > > Proposal:
> > > > The future format (Python 1.6 and newer) of a .pyc file should be as follows:
> > > >
> > > > bytes 0-3   a new magic number, which should be definitely frozen in 1.6.
> > > > bytes 4-7   a version number (which should be == 1 in Python 1.6)
> > > > bytes 8-11  timestamp (mtime of .py file) (same as earlier)
> > > > bytes 12-*  marshalled code object (same as earlier)

<snip/>

> A different approach to all this would be fixing only the
> first two bytes of the magic word, e.g.
> 
> byte 0: 'P'
> byte 1: 'Y'
> byte 2: version number (counting from 1)
> byte 3: option byte (8 bits: one for each option;
>                      bit 0: -U cmd switch)
> 
> This would be b/w compatible and still provide file(1)
> with enough information to be able to tell the file type.

I think this approach is simple and powerful enough
to survive Py3000.
Peter's approach is of course nicer and cleaner from
a "redo from scratch" point of view. But then, I'd even
vote for a better format that includes another field
which names the header size explicitly.

For simplicity, comapibility and ease of change,
I vote with +1 for adopting the solution of

byte 0: 'P'
byte 1: 'Y'
byte 2: version number (counting from 1)
byte 3: option byte (8 bits: one for each option;
                     bit 0: -U cmd switch)

If that turns out to be insufficient in some future,
do a complete redesign.

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer@appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     where do you want to jump today?   http://www.stackless.com