History of MAGIC number ?

Guido van Rossum guido at cnri.reston.va.us
Thu Jul 15 18:33:05 EDT 1999


Gregor Hoffleit <flight at mathi.uni-heidelberg.de> writes:

> I'd like to submit a patch to the maintainer of the Linux file command
> so that file recognizes Python .pyc and .pyo files.
> 
> .pyc and .pyo files are quiet easily recognizable on their magic
> number, a long word at the start of the file. The format of the long
> word is 32bit little endian, with the higher 16 bits set to 0x0a0d and 
> the lower 16 bits set to a pyc version number (20121 at the moment
> in Python 1.5.2).
> 
> Now if I want to write a robust test method for file I could either
> test for 0x0a0d in position 2 (which is not very rigid), or I had to
> list the explicit versions, like
> 
>   0  lelong   0x0a0d4e99    compiled Python code, magic version 20121
> 
> Now the problem is that this verion number has changed quite a few
> times in Python's history, but I can't find a list of the ancient
> values anywhere (Misc/HISTORY only lists the times changes took place, 
> but not the values).
> 
> Btw, should I say "Python bytecode" or "compiled Python code" ?

I would say Python bytecode; another acceptable term is compiled
Python module.

The history is in the CVS tree: http://www.python.org/download/cvs.html

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




More information about the Python-list mailing list