[Python-Dev] deprecating .pyo and -O (original) (raw)

R. David Murray rdmurray at bitdance.com
Thu Jun 14 15:14:59 CEST 2012


On Thu, 14 Jun 2012 14:14:54 +0200, Antoine Pitrou <solipsis at pitrou.net> wrote:

On Thu, 14 Jun 2012 12:58:16 +0100 Floris Bruynooghe <flub at devork.be> wrote: > On 14 June 2012 11:25, Antoine Pitrou <solipsis at pitrou.net> wrote: > > Honestly, I think the best option would be to deprecate .pyo files as > > well as the useless -O option. They only cause confusion without > > providing any significant benefits. > > +1 > > But what happens to debug and assert statements? I think it > should be possible to always put assert statements inside a debug > block and then create -O a simple switch for setting debug to > False. If desired a simple strip tool could then easily remove > debug blocks and (unused) docstrings.

I don't really see the point. In my experience there is no benefit to removing assert statements in production mode. This is a C-specific notion that doesn't really map very well to Python code. Do other high-level languages have similar functionality?

What does matter though is the memory savings. I'm working with an application where the difference between normal and -OO is around a 10% savings (about 2MB) in program DATA size at startup, and that makes a difference for an ap running in a memory constrained environment.

A docstring stripper would enable the bulk of that savings, but it is still nice to be able to omit code (such as debug logging statements) as well.

--David



More information about the Python-Dev mailing list