[Zope-dev] optimised python

Jim Fulton jim at zope.com
Mon Dec 19 06:50:19 EST 2005


Jens Vagelpohl wrote:
> 
> On 18 Dec 2005, at 06:46, Alan Milligan wrote:
> 
>> I'm reconsidering the way we RPM package byte-code compiled python,  and
>> although I suspect optimised python is a bit of an anacronysm, I  thought
>> I'd check with the list ;)
>>
>> If one was to start Zope with python -O, then it would look for (and
>> generate) .pyo files instead of .pyc's in all the Products right?
>>
>> Would there be any performance gain by this change?  How much?
>>
>> Is it worth me doing byte-compiles with -O and starting Zope's
>> interpreter in this mode?
> 
> 
> There is no anachronism at all. Building Python by hand will also  build 
> .pyo files alonside .pyc files. There is a speed increase  running Zope 
> with .pyos, but if I remember correctly you have to hack  one of the 
> startup files to correctly pass all python flags given  upon startup. I 
> don't know anyone who has done specific testing to  quantify the speed 
> increase, though.
> 
> There is a drawback: Debugging becomes a lot harder and sometimes  
> impossible because you get no or faulty line number information in  
> tracebacks and when using pdb.

That isn't true.  Line numbers are included and valid.

All -O does is:

- cause __debug__ to be false

- cause assert statements to be noop.

ZODB, and especially ZEO, have lots of logging calls conditioned on
__debug__, and running with -O can have a measurable (a few percent, If
I remember correctly) impact on performance especially when lots of
database access is going on.  I think this effect is more pronounced
for ZEO storage servers.

Production Zope and ZEO servers should run with -O IMO.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Zope-Dev mailing list