Łukasz Langa <luk...@langa.pl> added the comment: Python's AST already doesn't include a lot of syntax that has no runtime effect: - comments; - whitespace and punctuation.
The situation is now made "worse" with constant folding. You won't have full line information on the full expression, you don't even fully *see* expressions as syntactically provided by user code. The docstring is just a special case of that. As a counter example, it still includes function-level type annotations which are not evaluated. Clearly we don't have an explicit rule about this. If you asked *me*, I would say Python provides a "lossy" AST and this is the one it itself uses. It also provides a "lossless" AST and this one is in lib2to3. It's unfortunate that the latter is not documented and kind of neglected. This is something I want to address soonish. Summing up, I'm in favor of option 3. The AST preserves the docstring, it simply doesn't have information on where exactly it lives. In exchange, the tree makes it easier to *find* the docstring and easier to find the first instruction (as Serhiy points out, the first statement is now always code to be executed). Quoting literally the second sentence of the `ast` documentation: > The abstract syntax itself might change with each Python release. I am not against Option 2 since it's already implemented but I feel it's a pretty big change, pretty late in the release process for 3.7. The amount of work required *just* to preserve the line number of the docstring (which can be reasonably guessed anyway) seems silly to me. ---------- nosy: +lukasz.langa _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32911> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com