diff --git a/panel/layout/base.py b/panel/layout/base.py index 30931de79e..016f71bb41 100644 --- a/panel/layout/base.py +++ b/panel/layout/base.py @@ -388,16 +388,12 @@ def __iadd__(self, other: Iterable[Any]) -> ListLike: def __add__(self, other: Iterable[Any]) -> ListLike: if isinstance(other, ListLike): other = other.objects - else: - other = list(other) - return self.clone(*(self.objects+other)) + return self.clone(*self.objects, *other) def __radd__(self, other: Iterable[Any]) -> ListLike: if isinstance(other, ListLike): other = other.objects - else: - other = list(other) - return self.clone(*(other+self.objects)) + return self.clone(*other, *self.objects) def __contains__(self, obj: Viewable) -> bool: return obj in self.objects @@ -643,24 +639,26 @@ def __iadd__(self, other: Iterable[Any]) -> NamedListLike: return self def __add__(self, other: Iterable[Any]) -> NamedListLike: + added: Iterable if isinstance(other, NamedListLike): - added = list(zip(other._names, other.objects)) + added = zip(other._names, other.objects) elif isinstance(other, ListLike): added = other.objects else: - added = list(other) - objects = list(zip(self._names, self.objects)) - return self.clone(*(objects+added)) + added = other + objects = zip(self._names, self.objects) + return self.clone(*objects, *added) def __radd__(self, other: Iterable[Any]) -> NamedListLike: + added: Iterable if isinstance(other, NamedListLike): - added = list(zip(other._names, other.objects)) + added = zip(other._names, other.objects) elif isinstance(other, ListLike): added = other.objects else: - added = list(other) - objects = list(zip(self._names, self.objects)) - return self.clone(*(added+objects)) + added = other + objects = zip(self._names, self.objects) + return self.clone(*added, *objects) def __setitem__(self, index: int | slice, panes: Iterable[Any]) -> None: new_objects = list(self)