Skip to content

Commit 9f2cc4b

Browse files
Merge branch 'master' into for-loop-len-cache
2 parents 6e57a9c + 27b9ba0 commit 9f2cc4b

File tree

3 files changed

+26
-34
lines changed

3 files changed

+26
-34
lines changed

mypyc/irbuild/for_helpers.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -796,20 +796,6 @@ class ForSequence(ForGenerator):
796796

797797
length_reg: Value | AssignmentTarget | None
798798

799-
def __init__(
800-
self,
801-
builder: IRBuilder,
802-
index: Lvalue,
803-
body_block: BasicBlock,
804-
loop_exit: BasicBlock,
805-
line: int,
806-
nested: bool,
807-
length: Value | None = None,
808-
) -> None:
809-
super().__init__(builder, index, body_block, loop_exit, line, nested)
810-
self.length = length
811-
"""A Value representing the length of the sequence, if known."""
812-
813799
def init(self, expr_reg: Value, target_type: RType, reverse: bool) -> None:
814800
assert is_sequence_rprimitive(expr_reg.type), expr_reg
815801
builder = self.builder

mypyc/test-data/irbuild-generics.test

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -711,17 +711,18 @@ L0:
711711
r0 = __mypyc_self__.__mypyc_env__
712712
r1 = var_object_size args
713713
r2 = PyList_New(r1)
714-
r3 = 0
714+
r3 = var_object_size args
715+
r4 = 0
715716
L1:
716-
r4 = r3 < r1 :: signed
717-
if r4 goto L2 else goto L4 :: bool
717+
r5 = r4 < r3 :: signed
718+
if r5 goto L2 else goto L4 :: bool
718719
L2:
719-
r5 = CPySequenceTuple_GetItemUnsafe(args, r3)
720-
x = r5
721-
CPyList_SetItemUnsafe(r2, r3, x)
720+
r6 = CPySequenceTuple_GetItemUnsafe(args, r4)
721+
x = r6
722+
CPyList_SetItemUnsafe(r2, r4, x)
722723
L3:
723-
r6 = r3 + 1
724-
r3 = r6
724+
r7 = r4 + 1
725+
r4 = r7
725726
goto L1
726727
L4:
727728
can_listcomp = r2

mypyc/test-data/irbuild-tuple.test

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,27 +293,31 @@ def test():
293293
r3 :: tuple
294294
r4 :: native_int
295295
r5 :: bit
296-
r6, x, r7 :: str
297-
r8 :: native_int
296+
r6 :: native_int
297+
r7 :: bit
298+
r8, x, r9 :: str
299+
r10 :: native_int
298300
a :: tuple
299301
L0:
300302
r0 = 'abc'
301303
source = r0
302304
r1 = CPyStr_Size_size_t(source)
303305
r2 = r1 >= 0 :: signed
304306
r3 = PyTuple_New(r1)
305-
r4 = 0
307+
r4 = CPyStr_Size_size_t(source)
308+
r5 = r4 >= 0 :: signed
309+
r6 = 0
306310
L1:
307-
r5 = r4 < r1 :: signed
308-
if r5 goto L2 else goto L4 :: bool
311+
r7 = r6 < r4 :: signed
312+
if r7 goto L2 else goto L4 :: bool
309313
L2:
310-
r6 = CPyStr_GetItemUnsafe(source, r4)
311-
x = r6
312-
r7 = f2(x)
313-
CPySequenceTuple_SetItemUnsafe(r3, r4, r7)
314+
r8 = CPyStr_GetItemUnsafe(source, r6)
315+
x = r8
316+
r9 = f2(x)
317+
CPySequenceTuple_SetItemUnsafe(r3, r6, r9)
314318
L3:
315-
r8 = r4 + 1
316-
r4 = r8
319+
r10 = r6 + 1
320+
r6 = r10
317321
goto L1
318322
L4:
319323
a = r3
@@ -738,7 +742,8 @@ def test(source):
738742
L0:
739743
r0 = var_object_size source
740744
r1 = PyTuple_New(r0)
741-
r2 = 0
745+
r2 = var_object_size source
746+
r3 = 0
742747
L1:
743748
r3 = r2 < r0 :: signed
744749
if r3 goto L2 else goto L4 :: bool

0 commit comments

Comments
 (0)