Differences between revisions 5 and 7 (spanning 2 versions)
Revision 5 as of 2004-10-04 20:10:30
Size: 558
Editor: APuteaux-152-1-20-96
Comment: An @#! idiot had added some stupid spam on the page, I cleaned the mess
Revision 7 as of 2008-07-08 11:27:44
Size: 558
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
If you specify the '''optimize''' option in your ''setup.py'', this will only be used for the compiling of the needed modules, not for your main module![[BR]]For example if you have the following ''setup.py'': If you specify the '''optimize''' option in your ''setup.py'', this will only be used for the compiling of the needed modules, not for your main module!<<BR>>For example if you have the following ''setup.py'':
Line 16: Line 16:
To get optimised bytecode, you need to call the ''setup.py'' like so: To get optimized bytecode, you need to call the ''setup.py'' like so:

Problem

If you specify the optimize option in your setup.py, this will only be used for the compiling of the needed modules, not for your main module!
For example if you have the following setup.py:

   1 from distutils.core import setup
   2 import py2exe
   3 
   4 setup(
   5         options={"py2exe":{"optimize":2}},
   6         console=["beep.py"]
   7 )

The bytecode embedded in the resulting .exe will not be optimised.

Solution

To get optimized bytecode, you need to call the setup.py like so:

python -OO setup.py py2exe

OptimizedBytecode (last edited 2008-07-08 11:27:44 by localhost)