We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 71cda45 commit 4335273Copy full SHA for 4335273
mypyc/irbuild/for_helpers.py
@@ -26,6 +26,7 @@
26
StrExpr,
27
TupleExpr,
28
TypeAlias,
29
+ Var,
30
)
31
from mypyc.ir.ops import (
32
ERR_NEVER,
@@ -1202,6 +1203,14 @@ def get_expr_length(expr: Expression) -> int | None:
1202
1203
elif isinstance(expr, StarExpr):
1204
# star expression needs some extra logic but that can come later, this is good for now
1205
return get_expr_length(expr.expr)
1206
+ elif (
1207
+ isinstance(expr, RefExpr)
1208
+ and isinstance(expr.node, Var)
1209
+ and expr.node.is_final
1210
+ and isinstance(expr.node.final_value, str)
1211
+ and expr.node.has_explicit_value
1212
+ ):
1213
+ return len(expr.node.final_value)
1214
# TODO: extend this, unrolling should come with a good performance boost
1215
return None
1216
0 commit comments