gh-86620: Optimize constant slice creation#23496
gh-86620: Optimize constant slice creation#23496isidentical wants to merge 1 commit intopython:mainfrom
Conversation
|
Why do this in the AST optimizer, rather than the CFG optimizer? |
1dd4aef to
0a94ce9
Compare
How is this different than any kind of constant folding that we do in the AST optimizer? The only reason to move that I can think of is, having CFG to cover more cases than the AST optimizer (like the stuff compiler generates independently from the AST node) but I do not think it is a valid argument for slices (I can't think of any code path that the AST optimizer would miss). |
|
That wasn't a "please justify yourself" question, just an "I'm curious" question 🙂 It seems that neither optimizer turns |
|
A quick bit of experimentation shows that the CFG optimizer folds default values and annotations, which aren't handled by the AST optimizer. |
How can the CFG optimizer can do extra work on annotations? (Since PEP 563 is enabled by default, they are all strings)? For the default values, I believe this code path should optimize the defaults away, but if there is something wrong with it let's open an issue and discuss. Lines 620 to 621 in b9127dd |
|
Try it for yourself. Comment out |
It works fine for defaults? |
|
Try running the test suite, and look at the failures. I think it only happens in nested functions with defaults. Not sure why. |
|
Ah, I see. It is not related to the constant folding that I was speaking of (like folding a single default's value |
|
This PR is stale because it has been open for 30 days with no activity. |
|
@isidentical This has merge conflicts now. |
|
Should this PR and the associated issue be closed as totally abandoned? The conflicts are not resolved for at least six month. |
|
Yes. FTR, we plan to add a new instruction |
https://bugs.python.org/issue42454