[Python-Dev] Inconsistent behaviour in import/zipimport hooks

Guido van Rossum guido at python.org
Thu Nov 10 01:33:00 CET 2005


On 11/9/05, Phillip J. Eby <pje at telecommunity.com> wrote:
> 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).

That sounds very reasonable.

> 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.

Makes sense to me; we need a patch of course.

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


More information about the Python-Dev mailing list