mirror of https://github.com/tiangolo/fastapi.git
♻ 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:
parent
497e5a2422
commit
82775f7cd0
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue