[Python-Dev] Inconsistent behaviour in import/zipimport hooks
Phillip J. Eby
pje at telecommunity.com
Thu Nov 10 01:16:11 CET 2005
At 03:25 PM 11/9/2005 -0800, Guido van Rossum wrote:
>The only solutions I can think of that use a single file actually
>*increase* the file size by having unoptimized and optimized code
>side-by-side, or some way to quickly skip the assertions -- the -OO
>option is a special case that probably needs to be done differently
>anyway and only for final distribution.
We could have a "JUMP_IF_NOT_DEBUG" opcode to skip over asserts and "if
__debug__" blocks. Then under -O we could either patch this to a plain
jump, or compact the bytecode to remove the jumped-over part(s).
By the way, while we're on this subject, can we make the optimization
options be part of the compile() interface? Right now the distutils has to
actually exec another Python process whenever you want to compile code with
a different optimization level than what's currently in effect, whereas if
it could pass the desired level to compile(), this wouldn't be necessary.
More information about the Python-Dev
mailing list