Skip to content

[mypyc] feat: extend get_expr_length to try constant_fold_expr [1/4] - #19930

Merged
hauntsaninja merged 19 commits into
python:masterfrom
BobTheBuidler:patch-8
Dec 10, 2025
Merged

hauntsaninja merged 19 commits into
python:masterfrom
BobTheBuidler:patch-8

Conversation

@BobTheBuidler

@BobTheBuidler BobTheBuidler commented Sep 26, 2025 •

Copy link
Copy Markdown
Contributor

Among other things, get_expr_length currently supports StrExpr, BytesExpr, and string-type Final values.

constant_fold_expr already has the code to parse values from all of these, so we can use it to deduplicate code in get_expr_length.

It's able to parse a few more Expressions than our existing implementation, not that any of these are particularly relevant at the moment, and allows get_expr_length to automatically benefit from more relevant future constant-folding enhancements.

This PR is ready for review. All of the get_expr_length PRs are entirely independent and can be reviewed/merged in any order.

BobTheBuidler and others added 2 commits September 25, 2025 23:49
get_expr_len currently support StrExpr, BytesExpr, and string-type Final values

constant_fold_expr already has the code to parse values from all of these, so we can deduplicate code by using it

It's able to parse a few more Expressions than our existing implementation, and allows get_expr_length to automatically benefit from future constant-folding enhancements
@BobTheBuidler BobTheBuidler changed the title [mypyc] feat: extend get_expr_len to try constant_fold_expr Sep 26, 2025
@BobTheBuidler BobTheBuidler changed the title [mypyc] feat: extend get_expr_length to try constant_fold_expr Oct 1, 2025
@BobTheBuidler BobTheBuidler changed the title [mypyc] feat: extend get_expr_length to try constant_fold_expr [review me next plz] Oct 1, 2025
@hauntsaninja
hauntsaninja merged commit 0430236 into python:master Dec 10, 2025
@BobTheBuidler
BobTheBuidler deleted the patch-8 branch December 11, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants