[Python-Dev] Freeze hacks
Guido van Rossum
Wed, 18 Jul 2001 12:44:40 -0400
> > > 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:
since the optimizer only optimizes out "if 0:".
--Guido van Rossum (home page: http://www.python.org/~guido/)