Message286588
> 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.
> 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.
> 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.
> They are all NameConstant already.
Keep in mind this patch is 6 years old :) |
|
Date |
User |
Action |
Args |
2017-02-01 05:08:55 | eltoder | set | recipients:
+ eltoder, brett.cannon, georg.brandl, rhettinger, terry.reedy, gregory.p.smith, mark.dickinson, ncoghlan, pitrou, vstinner, techtonik, nadeem.vawda, benjamin.peterson, alex, Trundle, methane, dmalcolm, meador.inge, daniel.urban, Jeremy.Hylton, santoso.wijaya, eric.snow, jcon, berker.peksag, serhiy.storchaka, pconnell, isoschiz, pstch |
2017-02-01 05:08:54 | eltoder | set | messageid: <1485925734.85.0.416650798816.issue11549@psf.upfronthosting.co.za> |
2017-02-01 05:08:54 | eltoder | link | issue11549 messages |
2017-02-01 05:08:54 | eltoder | create | |
|