From f8f19b1a746d9317da5a80a44eff119323295577 Mon Sep 17 00:00:00 2001 From: Arun Prasad Date: Sun, 26 Oct 2025 19:06:44 +0000 Subject: [PATCH] perf: Avoid creating an intermediate container create a items tuple by combining first_items with extra_items and is not used in the reminder of the code. To make it more efficient we can check the items directly --- fastapi/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fastapi/utils.py b/fastapi/utils.py index 2e79ee6b1..e75c76077 100644 --- a/fastapi/utils.py +++ b/fastapi/utils.py @@ -247,8 +247,9 @@ def get_value_or_default( Otherwise, the first item (a `DefaultPlaceholder`) will be returned. """ - items = (first_item,) + extra_items - for item in items: + if not isinstance(first_item, DefaultPlaceholder): + return first_item + for item in extra_items: if not isinstance(item, DefaultPlaceholder): return item return first_item