Skip to content

Commit e8c74a6

Browse files
alexfiklinducer
authored andcommitted
avoid copy in flatten by not calling concatenate
1 parent 8f02514 commit e8c74a6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arraycontext/container/traversal.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,10 @@ def _flatten(subary: ArrayOrContainerT) -> None:
631631

632632
_flatten(ary)
633633

634-
return actx.np.concatenate(result)
634+
if len(result) == 1:
635+
return result[0]
636+
else:
637+
return actx.np.concatenate(result)
635638

636639

637640
def unflatten(

0 commit comments

Comments
 (0)