Message312482
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. |
|
Date |
User |
Action |
Args |
2018-02-21 09:16:37 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, brett.cannon, ncoghlan, vstinner, benjamin.peterson, yselivanov |
2018-02-21 09:16:37 | serhiy.storchaka | set | messageid: <1519204597.27.0.467229070634.issue32892@psf.upfronthosting.co.za> |
2018-02-21 09:16:37 | serhiy.storchaka | link | issue32892 messages |
2018-02-21 09:16:36 | serhiy.storchaka | create | |
|