mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-28 18:59:49 -04:00
♻ Refactor dict value extraction to minimize key lookups fastapi/utils.py (#3139)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
@@ -147,15 +147,15 @@ def generate_unique_id(route: "APIRoute") -> str:
|
||||
|
||||
|
||||
def deep_dict_update(main_dict: Dict[Any, Any], update_dict: Dict[Any, Any]) -> None:
|
||||
for key in update_dict:
|
||||
for key, value in update_dict.items():
|
||||
if (
|
||||
key in main_dict
|
||||
and isinstance(main_dict[key], dict)
|
||||
and isinstance(update_dict[key], dict)
|
||||
and isinstance(value, dict)
|
||||
):
|
||||
deep_dict_update(main_dict[key], update_dict[key])
|
||||
deep_dict_update(main_dict[key], value)
|
||||
else:
|
||||
main_dict[key] = update_dict[key]
|
||||
main_dict[key] = value
|
||||
|
||||
|
||||
def get_value_or_default(
|
||||
|
||||
Reference in New Issue
Block a user