diff --git a/CHANGES/9173.misc.rst b/CHANGES/9173.misc.rst new file mode 100644 index 00000000000..6fcc098747f --- /dev/null +++ b/CHANGES/9173.misc.rst @@ -0,0 +1 @@ +Improved performance of starting web requests when there is no response prepare hook -- by :user:`bdraco`. diff --git a/aiohttp/web_request.py b/aiohttp/web_request.py index aa5caea5311..d593a75da74 100644 --- a/aiohttp/web_request.py +++ b/aiohttp/web_request.py @@ -902,4 +902,5 @@ async def _prepare_hook(self, response: StreamResponse) -> None: if match_info is None: return for app in match_info._apps: - await app.on_response_prepare.send(self, response) + if on_response_prepare := app.on_response_prepare: + await on_response_prepare.send(self, response)