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

Tim Peters tim.one@home.com
Mon, 5 Feb 2001 14:37:46 -0500


> > byte 0:  \217  will never change
> > byte 1:  'P'   will never change
> > byte 2:  high-order byte of version number
> > byte 3:  low-order byte of version number

[Guido]
> +1 from me.  I'm +0 on adding more magic to the marshalled code.

Note that the suggested scheme cannot tolerate -U magically adding 1 to the
magic number, without getting strained ("umm, OK, we'll bump it by 2 when we
do it by hand, and then -U gets all the odd numbers"; "umm, OK, we'll use
'P' for regular Python and 'U' for Unicode Python"; etc).  So I say the
marshalled code at least needs to grow a flag field to handle -U and any
future extensions.  The "extended header" in the marshalled blob should also
begin with a 4-byte field giving the length of the extended header.

plan-for-change-ly y'rs  - tim