We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aacd618 commit de8c043Copy full SHA for de8c043
2 files changed
tests/micropython/heapalloc_yield_from.py
@@ -0,0 +1,31 @@
1
+# Check that yield-from can work without heap allocation
2
+
3
+import micropython
4
5
+# Yielding from a function generator
6
+def sub_gen(a):
7
+ for i in range(a):
8
+ yield i
9
+def gen(g):
10
+ yield from g
11
+g = gen(sub_gen(4))
12
+micropython.heap_lock()
13
+print(next(g))
14
15
+micropython.heap_unlock()
16
17
+# Yielding from a user iterator
18
+class G:
19
+ def __init__(self):
20
+ self.value = 0
21
+ def __iter__(self):
22
+ return self
23
+ def __next__(self):
24
+ v = self.value
25
+ self.value += 1
26
+ return v
27
+g = gen(G())
28
29
30
31
tests/micropython/heapalloc_yield_from.py.exp
@@ -0,0 +1,4 @@
+0
+1
0 commit comments