On Sun, Jan 27, 2013 at 4:58 PM, Victor Stinner <victor.stinner@gmail.com> wrote:
Why don't you compile using python -OO and distribute only .pyo code?

Because .pyo files can be much larger than necessary, e.g. using my mnfy project on decimal (with --safe-transforms) compared to -OO yields::

224K Lib/decimal.py
200K Lib/__pycache__/decimal.cpython-34.pyc
120K Lib/__pycache__/decimal.cpython-34.pyo
 80K decimal-mnfy.py

And before you ask, the bytecode is still larger on the minified source.

So if you truly want to shrink your binary plus overall memory usage footprint you want to go beyond -OO sometimes (although it is a cheap, fast way to save if you are not explicitly striving to eek out every byte).

-Brett

-Brett
 

Victor

2013/1/27 Kristján Valur Jónsson <kristjan@ccpgames.com>:
> We (CCP) are certainly compiling python without docstrings for our embedded platforms (that include the PS3)
> Anyone using python as en engine to be used by programs and not users will appreciate the deletion of unneeded memory.
> K
>
> -----Original Message-----
> From: Python-Dev [mailto:python-dev-bounces+kristjan=ccpgames.com@python.org] On Behalf Of R. David Murray
> Sent: 27. janúar 2013 00:38
> To: python-dev@python.org
> Subject: Re: [Python-Dev] Anyone building Python --without-doc-strings?
>
> On Sat, 26 Jan 2013 17:19:32 +0100, Antoine Pitrou <solipsis@pitrou.net> wrote:
>> On Sat, 26 Jan 2013 17:03:59 +0100
>> Stefan Krah <stefan@bytereef.org> wrote:
>> > Stefan Krah <stefan@bytereef.org> wrote:
>> > > I'm not sure how accurate the output is for measuring these
>> > > things, but according to ``ls'' and ``du'' the option is indeed quite worthless:
>> > >
>> > > ./configure CFLAGS="-Os -s" LDFLAGS="-s" && make
>> > >   1.8M Jan 26 16:36 python
>> > > ./configure --without-doc-strings CFLAGS="-Os -s" LDFLAGS="-s" && make
>> > >   1.6M Jan 26 16:33 python
>> >
>> > The original contribution *was* in fact aiming for "10% smaller", see:
>> >
>> > http://docs.python.org/release/2.3/whatsnew/node20.html
>> >
>> > So apparently people thought it was useful.
>>
>> After a bit of digging, I found the following discussions:
>> http://mail.python.org/pipermail/python-dev/2001-November/018444.html
>> http://mail.python.org/pipermail/python-dev/2002-January/019392.html
>> http://bugs.python.org/issue505375
>>
>> Another reason for accepting the patch seemed to be that it introduced
>> the Py_DOCSTR() macros, which were viewed as helpful for other reasons
>> (some people talked about localizing docstrings).
>>
>> I would point out that if 200 KB is really a big win for someone, then
>> Python (and especially Python 3) is probably not the best language for
>> them.
>>
>> It is also ironic how the executable size went up since then (from 0.6
>> to more than 1.5 MB) :-)
>
> 200K can make a difference.  It does on the QNX platform, for example, where there is no virtual memory.  It would be nice to reduce that executable size, too....but I'm not volunteering to try (at least not
> yet) :)
>
> --David
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/kristjan%40ccpgames.com
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com