From 540b662fb42401cb54c2765e3eefc1759ef21f92 Mon Sep 17 00:00:00 2001 From: Benedikt Johannes Date: Sun, 22 Feb 2026 14:10:12 +0100 Subject: [PATCH] Slightly improve performance in engines/utils.py Signed-off-by: Benedikt Johannes --- monai/engines/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monai/engines/utils.py b/monai/engines/utils.py index 9095f8d943..baeafd5081 100644 --- a/monai/engines/utils.py +++ b/monai/engines/utils.py @@ -219,8 +219,8 @@ def __call__( `kwargs` supports other args for `Tensor.to()` API. """ image, label = default_prepare_batch(batchdata, device, non_blocking, **kwargs) - args_ = list() - kwargs_ = dict() + args_ = [] + kwargs_ = {} def _get_data(key: str) -> torch.Tensor: data = batchdata[key] @@ -235,7 +235,7 @@ def _get_data(key: str) -> torch.Tensor: args_.append(_get_data(k)) elif isinstance(self.extra_keys, dict): for k, v in self.extra_keys.items(): - kwargs_.update({k: _get_data(v)}) + kwargs_[k] = _get_data(v) return cast(torch.Tensor, image), cast(torch.Tensor, label), tuple(args_), kwargs_