Control of __doc__ strings

Nils Hensel nils.hensel at online.de
Mon Jan 22 16:25:16 EST 2001


You must invoke python with the -OO argument. This will exclude debugging
info and doc strings from the bytecode.
Try "python --help" for more info.

Enjoy Python,
Nils


"Terry Hancock" <hancock at earthlink.net> schrieb im Newsbeitrag
news:mailman.980197704.24948.python-list at python.org...
> Following a previous thread on this list about
> automatic documenters, I've tried a couple,
> and there seems to be a strong preference for
> documentation strings over comments (they seem
> to be easier to associate with the object they
> describe, which makes sense to me).
>
> Anyway, not being a "native python speaker"
> I used comments in most of my code.  So I changed
> my comment blocks to doc strings and put them
> in the right places to get captured by the
> documenter ("Crystal" in this case).  But I'm
> concerned about the performance penalties of
> doing this.  A typical source module of mine
> contains anywhere from 3 to 5 times as much text
> in comment blocks as in the code, so if it's
> all loaded at run time, my code is going to bloat
> up several fold just because of the documentation.
>
> (Comments are stripped out during byte-compilation,
> whereas doc strings are kept at run time).
>
> Does python have a way to shut off a piece of
> code during byte-compiling (the way that a
> #ifdef ... #endif block works in C)?  Then I
> could just turn the doc strings off for deliverable
> code and leave them in during development, which
> would be kind of useful, and the documenters would
> work right.
>
> I thought of:
>
> if <condition> :
>     """
>     Documentation block.
>     """
>
> but this runs at run-time, therefore the string is
> still included in the byte-compiled code (right?).
>
> --
> Terry Hancock
> hancock at earthlink.net
>





More information about the Python-list mailing list