[Python-ideas] Dump .pyo and the "optimize" flag

Nick Coghlan ncoghlan at gmail.com
Tue Feb 2 21:58:22 CET 2010


Antoine Pitrou wrote:
> Larry Hastings <larry at ...> writes:
>> I ask you: why gunk up the filesystem with two files when one would do?  
>> I propose we change the pyc file so it can contain multiple code 
>> objects.
> 
> I think we should dump the lie about "optimized" bytecode when the only
> optimization is that we strip some docstrings, disable asserts and set __debug__
> to False.

The fact that asserts and if __debug__ blocks get skipped under -O
strikes me as more than adequate reason to consider optimised and
non-optimised bytecode as different things. Sure, we don't mess with
things as extensively as C/C++ do with their more aggressive
optimisation settings, but completely skipping all assert statements and
some if statements isn't something we can enable by default (and can't
necessarily do with an after-the-fact stripping tool, since the removal
of entire statements can affect the construction of the symbol table).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------



More information about the Python-ideas mailing list