This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients Jeremy.Hylton, Trundle, alex, benjamin.peterson, berker.peksag, brett.cannon, daniel.urban, dmalcolm, eltoder, eric.snow, georg.brandl, gregory.p.smith, isoschiz, jcon, mark.dickinson, meador.inge, methane, nadeem.vawda, ncoghlan, pconnell, pitrou, pstch, rhettinger, santoso.wijaya, serhiy.storchaka, techtonik, terry.reedy, vstinner
Date 2017-02-01.06:29:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1485930555.34.0.717877154176.issue11549@psf.upfronthosting.co.za>
In-reply-to
Content
>> 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.
History
Date User Action Args
2017-02-01 06:29:15methanesetrecipients: + methane, brett.cannon, georg.brandl, rhettinger, terry.reedy, gregory.p.smith, mark.dickinson, ncoghlan, pitrou, vstinner, techtonik, nadeem.vawda, benjamin.peterson, alex, Trundle, dmalcolm, meador.inge, daniel.urban, Jeremy.Hylton, santoso.wijaya, eltoder, eric.snow, jcon, berker.peksag, serhiy.storchaka, pconnell, isoschiz, pstch
2017-02-01 06:29:15methanesetmessageid: <1485930555.34.0.717877154176.issue11549@psf.upfronthosting.co.za>
2017-02-01 06:29:15methanelinkissue11549 messages
2017-02-01 06:29:14methanecreate