[Python-ideas] Dump .pyo and the "optimize" flag
Brett Cannon
brett at python.org
Tue Feb 2 21:49:07 CET 2010
On Tue, Feb 2, 2010 at 07:16, Antoine Pitrou <solipsis at pitrou.net> 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.
I think the hope has always been that the peepholer would be extended
to do some tweaks that would only be reasonable under a -O flag.
Obviously this has not happened and who knows if it ever will.
But if PEP 3147 catches on this should become less of an issue.
>
> There should be only one possible bytecode file (XXX.pyc), and we could provide
> a "strip" tool (and/or corresponding function in the compileall module) for
> people for whom minimizing bytecode file size is important.
Would also require a flag for distutils for when you are installing a
package that is for production compared to debug use you byte-compile
to the level you want. But I think the compileall/strip/distutils
solution would be enough to cover all major cases.
>
> Also, it would be interesting to know who bothers to use "python -O" (or "-OO").
> I know I never use it.
Do any other languages do it this way with separate files? Or do they
tend toward not even having the option and the few that do use a strip
tool? I honestly can't think of any languages off the top of my head
where the -O flag is even actively considered by everyone beyond
C/C++.
-Brett
>
>
> Antoine.
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
More information about the Python-ideas
mailing list