Docstrings and PEP 3174

Carl Banks pavlovevidence at gmail.com
Sun Aug 1 04:52:05 CEST 2010


PEP 3174 got me to thinking.

There is now a subdirectory to deposit as many *.pyc files as you want
without cluttering the source directory (never mind the default
case).  Which means you can pretty much write files with impunity.

So I was wondering: what about a separate file just for docstrings.
__doc__ would become a descriptor that loads the docstring from the
file whenever it is referenced.  The vast majority of the time
docstrings just take up memory and do nothing, so why not lazy load
those things?

Yes I know you can use the -OO switch to omit docstrings--but who does
that anyway?  I know I never use -O because I don't know if the people
who wrote the library code I'm using were careful enough not to
perform general checks with assert or to avoid relying on the
docstring's presense.

Yeah, it's probably a miniscule optimization, but whatever, I'm just
throwing it out there.

Carl Banks



More information about the Python-list mailing list