[PEAK] DecoratorTools and python -OO

P.J. Eby pje at telecommunity.com
Fri Apr 30 18:59:45 EDT 2010


At 04:35 PM 4/30/2010 -0600, Jim Meier wrote:
>We're trying to cut down the memory usage of our system, and it looks
>like one area that might help is to use python's -OO flag to strip
>docstrings from the bytecode. This works reasonable well as far as it
>goes, but runs into an issue where DecoratorTools is using a function's
>__doc__ attribute to store some code templates. Under -OO, __doc__ is
>set to None, which causes a traceback when apply_template tried to
>access the nonexistent replace method on it. Simply using an alternate
>attribute resolves the problem.
>
>Attached is a patch that uses the attribute "__template__".

Unfortunately, this patch won't work - it's not just DecoratorTools 
that would have to change, it's every library that *uses* DecoratorTools.  See:

http://www.eby-sarna.com/pipermail/peak/2009-December/003319.html

for more info.

(As a workaround, have you tried compiling the bytecode for affected 
modules with -O, and then running the interpreter with -OO?  A bit 
hacky, but if you're that desperate for memory...  what sort of 
system are you building, anyway, where docstrings are a significant 
part of your memory footprint?)



More information about the PEAK mailing list