[issue42754] Unpacking of literals inside other literals should be optimised away by the compiler

2020-12-28 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > This is a similar case. I am -1 for this optimization. Yeah, I concur. One of the major drawbacks of this is that the normal case where this happens involves a Load(): z = "something" x = ["a", *z, "b"] I see almost no reason to nest the literals

[issue42754] Unpacking of literals inside other literals should be optimised away by the compiler

2020-12-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I do not think there are serious raesons for adding this optimization. The Python compiler was intentionally made simple for maintainability. Constant folding supports only base arithmetic and bits operations because they are often used in constant

[issue42754] Unpacking of literals inside other literals should be optimised away by the compiler

2020-12-28 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I have added a draft PR on how the idea would look like so we can discuss with a specific proposal. -- ___ Python tracker ___

[issue42754] Unpacking of literals inside other literals should be optimised away by the compiler

2020-12-28 Thread Pablo Galindo Salgado
Change by Pablo Galindo Salgado : -- keywords: +patch pull_requests: +22824 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23979 ___ Python tracker

[issue42754] Unpacking of literals inside other literals should be optimised away by the compiler

2020-12-28 Thread Batuhan Taskaya
Batuhan Taskaya added the comment: We could possibly fold this at the AST optimizer, though I am not sure whether this worths anything as an optimization since it is a real obscure pattern. I've only found 2 occurrences (both from the test suite of black) on a relatively ~big dataset of

[issue42754] Unpacking of literals inside other literals should be optimised away by the compiler

2020-12-28 Thread Batuhan Taskaya
Change by Batuhan Taskaya : -- Removed message: https://bugs.python.org/msg383911 ___ Python tracker ___ ___ Python-bugs-list

[issue42754] Unpacking of literals inside other literals should be optimised away by the compiler

2020-12-28 Thread Batuhan Taskaya
Batuhan Taskaya added the comment: We could possibly fold this at the AST optimizer, though I am not sure whether this worths anything as an optimization since it is a real obscure pattern. I've only found 2 occurrences (both from a test set on a relatively ~big dataset of source code.

[issue42754] Unpacking of literals inside other literals should be optimised away by the compiler

2020-12-28 Thread Batuhan Taskaya
Change by Batuhan Taskaya : -- nosy: +BTaskaya ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42754] Unpacking of literals inside other literals should be optimised away by the compiler

2020-12-26 Thread Patrick Reader
Change by Patrick Reader : -- type: -> performance ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42754] Unpacking of literals inside other literals should be optimised away by the compiler

2020-12-26 Thread Patrick Reader
New submission from Patrick Reader : When unpacking a collection or string literal inside another literal, the compiler should optimise the unpacking away and store the resultant collection simply as another constant tuple, so that `[*'123', '4', '5']` is the exact same as `['1', '2', '3',