[PEAK] DecoratorTools and python -OO

P.J. Eby pje at telecommunity.com
Wed May 5 14:13:36 EDT 2010


At 04:35 PM 4/30/2010 -0600, Jim Meier wrote:
>Hi folks, I hope this is the right list. If not, please direct me to the
>best place for DecoratorTools development discussion.
>
>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__".

Hi Jim.  I've implemented an alternative fix for this in SVN; use:

    easy_install svn://svn.eby-sarna.com/svnroot/DecoratorTools/

to update.  The change is that instead of a docstring or function 
attribute, I use the template function's return value.  There's also 
an improved error message for the case where someone's still using 
the docstring approach and you're running -OO.

Please let me know if this update works for you; I'd like to get some 
feedback before cutting an official release on PyPI.  Thanks. 



More information about the PEAK mailing list