New submission from Gregory P. Smith <g...@krypto.org>:

I'm spawning this issue of as a separate feature from 
https://bugs.python.org/issue36906 (adding string dedent method and an 
optimization to do it at compile timer on constants).

It'd be great if docstrings were given a similar treatment.  Right now we carry 
the whitespace burden within the str constants for __doc__ stored in all code 
objects in the process.  This adds up.

This is not _quite_ the same as calling textwrap.dedent() or the upcoming 
str.dedent method on them at compile time.  We need to special case the first 
line of docstrings.  inspect.getdoc() is our library function that does this 
for us today.

Change of breaking things with this change?  not impossible, but extremely 
minor.  Something using docstrings as data _and_ depending on leading 
indentation whitespace preservation would not like this.  I am not aware of 
anything that would ever do that.

----------
components: Interpreter Core
messages: 343990
nosy: gregory.p.smith
priority: normal
severity: normal
status: open
title: Automatically dedent docstring constants by default
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37102>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to