dispatcher: cache dispatch calls
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 18 Jun 2023 18:52:19 +0000 (21:52 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sun, 18 Jun 2023 18:52:19 +0000 (21:52 +0300)
src/mdis/dispatcher.py

index 3825b9efc5be94c3097daf8142465f48053f9e78..a23cd027315ec64ba77ff35ae5e354bf0fba63ac 100644 (file)
@@ -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: