STINNER Victor <vstin...@redhat.com> added the comment:

IMHO Python 3.7 will be simpler to process, since it avoids to check if the 
first node is a docstring or not.

I agree that it's a backward incompatible, but it has been done on purpose. In 
fact, there is no warranty about backward compatibility on the genreated AST 
between Python versions (like 3.6 vs 3.7).

As Lukasz wrote, AST of Python 3.6 already omit a lot of information about 
formatting, we are far from a 1:1 mapping between code and AST. For example, 
tools to "unparse" AST breaks the formatting. The Python 'ast' module is just 
not appropriate for such use case. There are other solutions for that, like 
lib2to3.

Having a docstring attribute *and* a docstring node seem to be redundant to be, 
or more like a bug. Redundant data can quickly lead to inconsistencies.

The current trend is more to move the AST away from the original Python source 
code, to produce better AST, especially in term of performance. That's also why 
I added the ast.Constant node type ;-) And why many peephole optimizations have 
been reimplemented at the AST level, rather than on the bytecode level.

----------

_______________________________________
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

Reply via email to