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 serhiy.storchaka
Recipients benjamin.peterson, brett.cannon, gvanrossum, ncoghlan, serhiy.storchaka, vstinner, yselivanov
Date 2018-02-21.09:16:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519204597.27.0.467229070634.issue32892@psf.upfronthosting.co.za>
In-reply-to
Content
Currently different literals are represented by different types in AST:

Num -- for int, float and complex
Str -- for str
Bytes -- for bytes
Ellipsis -- for Ellipsis
NameConstant -- for True, False and None

And Constant (added in 3.6, issue26146) can represent any immutable value, including tuples and frozensets of constants. Instances of Constant are not created by the AST parser, they are created by the builtin AST optimizer and can be created manually.

These AST types don't have one-to-one correspondence with Python types, since Num represents three numeric types, NameConstant represents bool and NoneType, and any constant type can be represented as Constant.

I propose to get rid of Num, Str, Bytes, Ellipsis and NameConstant and always use Constant. This will simplify the code which currently needs to repeat virtually identical code for all types.

I have almost ready patch, the only question is whether it is worth to keep deprecated aliases Num, Str, Bytes, Ellipsis and NameConstant.
History
Date User Action Args
2018-02-21 09:16:37serhiy.storchakasetrecipients: + serhiy.storchaka, gvanrossum, brett.cannon, ncoghlan, vstinner, benjamin.peterson, yselivanov
2018-02-21 09:16:37serhiy.storchakasetmessageid: <1519204597.27.0.467229070634.issue32892@psf.upfronthosting.co.za>
2018-02-21 09:16:37serhiy.storchakalinkissue32892 messages
2018-02-21 09:16:36serhiy.storchakacreate