[Python-Dev] #12982: Should -O be required to *read* .pyo files?
Steven D'Aprano
steve at pearwood.info
Thu Jun 14 02:55:59 CEST 2012
On Wed, Jun 13, 2012 at 01:58:10PM -0400, R. David Murray wrote:
> So, is there any reason to not use the .pyo file (if that's all that is
> around) when -O is not specified?
.pyo and .pyc files have potentially different semantics. Right now,
.pyo files don't include asserts, so that's one difference right there.
In the future there may be more aggressive optimizations.
Good practice is to never write an assert that actually changes the
semantics of your program, but in practice people don't write asserts
correctly, e.g. they use them for checking user-input or function
parameters.
So, no, we should never use .pyo files unless explicitly told to do so,
since doing so risks breaking poorly-written but otherwise working code.
--
Steven
More information about the Python-Dev
mailing list