[Python-Dev] Freeze hacks
Wed, 18 Jul 2001 18:50:34 +0200
From: "Guido van Rossum" <email@example.com>
> > > > Very good idea IMO, but 'if 0:' is optimized away.
> > >
> > > I'm not sure I understand. freeze does not optimize away such a code
> > > block. Under which condition is that optimized away?
> > >
> > The Python compiler itself. 'if 0: import whatever' does
> > not generate any byte code. Modulefinder (used by freeze,
> > py2exe, and Gordon's installer) checks the compiled byte code
> > for import statements.
> Good catch, Thomas.
> I find defining a variable _FAKE a bit cumbersome as a work-around. I
> would suggest instead:
> if 1==0:
> import whatever
> since the optimizer only optimizes out "if 0:".
If the optimizer becomes more intelligent
in the future, and also probably easier to document
the purpose would be to use an (uncalled) function:
Just another idea,