[Python-Dev] PYC Magic

Tim Peters tim.one@comcast.net
Sun, 10 Feb 2002 17:45:34 -0500


[MAL]
> Wait... the -U option was added in order to be able to see how well
> the 8-bit string / Unicode integration works. It's a know fact that
> the Python standard lib is not Unicode compatible yet and that's
> exactly what the -U option allows you to test (in a very simple
> way).

I don't object to testing hacks provided they don't trip up the innocent; it
would help to remove -U from the user-visible docs (which I'll do).  Note
that, by coincidence, Andreas Jung (at Zope Corp) pissed away time worrying
about -U breakage yesterday independent of our thread here:  it's doing
harm.

If you're the only one who tries -U on purpose (anyone?  it's clear that I
don't ...), it would be better done via a preprocessor define.  How often is
this used even by you?  If it's once per release just to make sure it's
still broken <wink>, a variant build wouldn't be a real burden.

> ...
> The -U option is currently the only application of such a flag.
> We will definitely have a need for these options in the future
> to make the runtime aware of certain assumptions which have been
> made in the compiled byte code, e.g. byte code using special
> opcodes, byte code compiled for a different Python virtual
> machine (once we get pluggable Python compiler / VM combos),
> byte code which was compiled using special literal
> interpretations (such as in the -U case or when compiling
> the source code with a different source code encoding
> assumption).

There remains no current use for any of these things.  When a real use
appears, "magic number" abuse won't be appropriate:  imp.get_magic() doesn't
return a vector; we're not doing the Unixish /etc/magic database any favors
by *ever* changing it; and needing to register umpteen distinct magic
numbers per release for Linux binfmt would make Python even more irritating
to live with there.

> I would be more than happy to get rid off the current PYC magic hack
> for -U and have it replaced with a better and extensible alternative,
> e.g. a combination of PYC version number and marhsalled option
> dictionary.

I agree, except that I still think having -U now is a net loss.