From 50405fae5f4f3e55a664d3efcdf3283e0ddd48a3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 27 Apr 2024 18:42:29 -0500 Subject: [PATCH] Add a cache to _verify_event_type_length_or_raise (#116312) Most of the time the events being fired are the same so we can skip the python code in this function --- homeassistant/core.py | 1 + 1 file changed, 1 insertion(+) diff --git a/homeassistant/core.py b/homeassistant/core.py index a2808568f29..37baffa6f19 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -1408,6 +1408,7 @@ class _OneTimeListener(Generic[_DataT]): EMPTY_LIST: list[Any] = [] +@functools.lru_cache def _verify_event_type_length_or_raise(event_type: EventType[_DataT] | str) -> None: """Verify the length of the event type and raise if too long.""" if len(event_type) > MAX_LENGTH_EVENT_EVENT_TYPE: