Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e81a5ce
feat: cache len for iterating over immutable types
BobTheBuidler Aug 4, 2025
804c3b5
fix: tests
BobTheBuidler Aug 4, 2025
33d64b3
fix: include bytes as sequence and fix test
BobTheBuidler Aug 4, 2025
34c2244
rtypes
BobTheBuidler Aug 4, 2025
58b18ee
Update for_helpers.py
BobTheBuidler Aug 4, 2025
aef2732
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2025
3bd549c
Update for_helpers.py
BobTheBuidler Aug 4, 2025
48a3671
Update specialize.py
BobTheBuidler Aug 4, 2025
3f7ba01
Update irbuild-tuple.test
BobTheBuidler Aug 4, 2025
74b89d8
Delete mypyc/test-data/fixtures/tuple.pyi
BobTheBuidler Aug 4, 2025
05b6f53
feat: len only once
BobTheBuidler Aug 4, 2025
4c95554
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2025
83ee9aa
Update for_helpers.py
BobTheBuidler Aug 4, 2025
d8dd01a
Update for_helpers.py
BobTheBuidler Aug 4, 2025
b16e023
Update for_helpers.py
BobTheBuidler Aug 4, 2025
8f5f59e
Update for_helpers.py
BobTheBuidler Aug 4, 2025
a0f2ac0
Update for_helpers.py
BobTheBuidler Aug 4, 2025
47f1d3f
Update for_helpers.py
BobTheBuidler Aug 4, 2025
bf7520a
Update irbuild-tuple.test
BobTheBuidler Aug 4, 2025
558b1af
feat: handle star expr
BobTheBuidler Aug 4, 2025
24c67d3
feat(test): test final and list
BobTheBuidler Aug 4, 2025
f09ef04
feat: propagate length of final strings
BobTheBuidler Aug 4, 2025
0a0508b
feat(test): test containers from literal exprs
BobTheBuidler Aug 4, 2025
ed4239b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 4, 2025
7eb67a3
Update for_helpers.py
BobTheBuidler Aug 4, 2025
e9f0451
Update for_helpers.py
BobTheBuidler Aug 4, 2025
537c8af
feat(test): test stars
BobTheBuidler Aug 4, 2025
888b971
Update for_helpers.py
BobTheBuidler Aug 4, 2025
2b0cb4b
Update for_helpers.py
BobTheBuidler Aug 7, 2025
6e57a9c
Merge branch 'master' into for-loop-len-cache
BobTheBuidler Aug 13, 2025
9f2cc4b
Merge branch 'master' into for-loop-len-cache
BobTheBuidler Aug 14, 2025
62dbc11
Update for_helpers.py
BobTheBuidler Aug 14, 2025
99e44d3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 14, 2025
b19ad91
Update irbuild-tuple.test
BobTheBuidler Aug 14, 2025
e2742e9
Update irbuild-tuple.test
BobTheBuidler Aug 14, 2025
b9317bc
Update irbuild-generics.test
BobTheBuidler Aug 14, 2025
0869a2f
Update irbuild-tuple.test
BobTheBuidler Aug 16, 2025
074b772
Merge branch 'master' into for-loop-len-cache
BobTheBuidler Aug 17, 2025
bec2e92
Update irbuild-tuple.test
BobTheBuidler Aug 19, 2025
79e1009
Update irbuild-generics.test
BobTheBuidler Aug 19, 2025
69bd43d
Merge branch 'master' into for-loop-len-cache
BobTheBuidler Aug 21, 2025
1fa74d3
Merge branch 'master' into for-loop-len-cache
BobTheBuidler Aug 23, 2025
29c62b3
Merge branch 'master' into for-loop-len-cache
BobTheBuidler Aug 30, 2025
625929f
add run tests
BobTheBuidler Sep 8, 2025
44244e0
Update run-tuples.test
BobTheBuidler Sep 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update for_helpers.py
  • Loading branch information
BobTheBuidler committed Aug 4, 2025
commit 8f5f59ed738ebbc9cda8daa257566f85ee42c0e1
11 changes: 9 additions & 2 deletions mypyc/irbuild/for_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,8 +1192,15 @@ def get_expr_length(expr: Expression) -> int | None:
if isinstance(expr, (StrExpr, BytesExpr)):
return len(expr.value)
elif isinstance(expr, (ListExpr, TupleExpr)):
if all(get_expr_length(i) is not None for i in expr.items):
return len(expr.items)
# if there are no star expressions, or we know the length of them,
# we know the length of the expression
stars = [get_expr_length(i, context) for i in expr.items if isinstance(i, StarExpr)]
if None not in stars:
other = sum(not isinstance(i, StarExpr) for i in expr.items)
return other + sum(stars)
elif isinstance(expr, StarExpr):
# star expression needs some extra logic but that can come later, this is good for now
pass
# TODO: extend this, unrolling should come with a good performance boost
return None

Expand Down