From b63709fa641bf63c20a409c73e47c1f585772e21 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 18 Jun 2023 21:52:19 +0300 Subject: [PATCH] dispatcher: cache dispatch calls --- src/mdis/dispatcher.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mdis/dispatcher.py b/src/mdis/dispatcher.py index 3825b9e..a23cd02 100644 --- a/src/mdis/dispatcher.py +++ b/src/mdis/dispatcher.py @@ -5,6 +5,7 @@ __all__ = [ ] import collections +import functools import inspect import types @@ -68,6 +69,7 @@ class DispatcherMeta(type): return super().__new__(metacls, name, bases, ns) + @functools.lru_cache(maxsize=None) def dispatch(cls, typeid=object): hook = cls.__hooks__.get(typeid) if hook is not None: -- 2.30.2