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

M.-A. Lemburg mal@lemburg.com
Mon, 05 Feb 2001 20:50:26 +0100


Tim Peters wrote:
> 
> [M.-A. Lemburg]
> > Side note: the magic can also change due to command line options
> > being used, e.g. -U will bump the magic number by 1.
> 
> Note that this (-U) is the only such case.  Unless people are using private
> Python variants and adding their own cmdline switches that fiddle the magic
> number <yikes>.

I think that future optimizers or special combinations of the
yet-to-be-designed Python compiler/VM toolkit will make some use
of this feature too. It is currently the only way to prevent the
interpreter from loading code which it potentially cannot execute.

When redesigning the import magic, we should be careful to allow
future combinations of compiler/VM to introduce new opcodes etc.
so there will have to be some field for them to use too. The -U
trick is really only a hack in that direction (since it modifies
the compiler and thus the generated byte code).

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company:                                        http://www.egenix.com/
Consulting:                                    http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/