[Python-ideas] A new .pyc file format

Blake Winton bwinton at latte.ca
Fri Apr 25 16:33:16 CEST 2008

Gabriel Genellina wrote:
> I propose using a more flexible .pyc format (resembling RIFF files with
 > multiple levels). The layout would be as follows:
> - A file contains a sequence of sections.
> - A section has an identifier (4 bytes, usually ASCII letters),


> New sections -or subsections inside a section- can be defined in the
> future. No implied knowledge of section meanings or its structure is
> required to read the file; readers can safely skip over sections they
> don't understand, and never lost synchronism.

As a side suggestion, the PNG spec makes the capitalization of each 
identifier indicate extra meta-data about the section.  (See: 

For instance, an identifier that starts with a capital letter means that 
  the decoder must understand this chunk to process the contents of the 
file, whereas an identifier with a lowercase first letter can safely be 

An uppercase second letter means that the identifier is defined by 
Python, whereas a lowercase second letter would indicate a 
third-party-defined chunk.

(The PNG spec reserves the case of the third letter, and forces it to be 
uppercase.  The case of the fourth letter indicates whether it's safe to 
copy this chunk.  I don't think either of those are particularly useful 
to Python, and so could conveniently be skipped.)

Would this extra meta-data be useful?  I think so, for the "safe to 
ignore" flag, at least.


More information about the Python-ideas mailing list