INADA Naoki added the comment: >> We have already Constant and NameConstant. So it seems there are no need for >> None, Bool, TupleConst, SetConst nodes. > Yes, Constant is Victor's version of Lit.
Then, may I remove ast.Lit, and use Constant and NameConstant? >> I think converting Num, Str, Bytes, Ellipsis into Constant in folding stage >> is easier than fixing all tests. > Fixing tests was fairly easy the last time. I think the question is what > changes to the public API of AST are acceptable. I think backward compatibility is not guaranteed. But there are some usage of ast. (https://github.com/search?l=Python&p=2&q=ast.Num&type=Code&utf8=%E2%9C%93 ) So I think we should make change small as possible. >> Take docstring before constant folding isn't enough? >> (I'm sorry if I'm wrong. I haven't tried it yet.) > It may be doable, but seems very messy. Instead of a clean pipeline text -> > AST -> Optimized AST -> bytecode, you have to collect all docstrings, and > pass them around in a side structure. > > With the current code there can be a simple fix. If original string literals > are Str, but constant-folded string constants are Constant, only treat Strs > as docstrings. Then the optimizer needs a change to always preserve Str as a > first statement in a function/module, and that's it. > I still think that having a dedicated docstring attribute in AST is cleaner, > though. OK. >> They are all NameConstant already. > Keep in mind this patch is 6 years old :) I know. I want to move this patch forward, but I'm not frontend (parser, AST, and compiler) expert. I can't make design decision without expert's advice. Thanks for your reply. Then, may I update the patch in following direction? * Remove ast.Lit. * Keep docstring change. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11549> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com