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 f3521153603..f7e511fa477 100644 --- a/aiohttp/web_request.py +++ b/aiohttp/web_request.py @@ -915,4 +915,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)