Skip to content

Commit c2e87a5

Browse files
authored
stream_eval cleanup
1 parent ff00223 commit c2e87a5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

unification/core.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,27 @@ def stream_eval(z, res_filter=None):
3131
if not isinstance(z, Generator):
3232
return z
3333

34-
stack = deque()
34+
stack = deque([z])
3535
z_args, z_out = None, None
36-
stack.append(z)
3736

3837
while stack:
3938
z = stack[-1]
4039
try:
4140
z_out = z.send(z_args)
4241

43-
if res_filter:
44-
_ = res_filter(z, z_out)
42+
if res_filter is not None:
43+
res_filter(z, z_out)
4544

45+
except StopIteration:
46+
stack.pop()
47+
48+
else:
4649
if isinstance(z_out, Generator):
4750
stack.append(z_out)
4851
z_args = None
4952
else:
5053
z_args = z_out
5154

52-
except StopIteration:
53-
_ = stack.pop()
54-
5555
return z_out
5656

5757

0 commit comments

Comments
 (0)