@@ -209,9 +209,6 @@ class LRUCache(Generic[T, U]):
209209    CacheInfo(hits=194, misses=99, capacity=100, current size=99) 
210210    """ 
211211
212-     # class variable to map the decorator functions to their respective instance 
213-     decorator_function_to_instance_map : dict [Callable [[T ], U ], LRUCache [T , U ]] =  {}  # noqa: RUF012 
214- 
215212    def  __init__ (self , capacity : int ):
216213        self .list : DoubleLinkedList [T , U ] =  DoubleLinkedList ()
217214        self .capacity  =  capacity 
@@ -308,18 +305,21 @@ def decorator(
308305        """ 
309306
310307        def  cache_decorator_inner (func : Callable [[T ], U ]) ->  Callable [..., U ]:
308+             # variable to map the decorator functions to their respective instance 
309+             decorator_function_to_instance_map : dict [Callable [[T ], U ], LRUCache [T , U ]] =  {}
310+ 
311311            def  cache_decorator_wrapper (* args : T ) ->  U :
312-                 if  func  not  in   cls . decorator_function_to_instance_map :
313-                     cls . decorator_function_to_instance_map [func ] =  LRUCache (size )
312+                 if  func  not  in   decorator_function_to_instance_map :
313+                     decorator_function_to_instance_map [func ] =  LRUCache (size )
314314
315-                 result  =  cls . decorator_function_to_instance_map [func ].get (args [0 ])
315+                 result  =  decorator_function_to_instance_map [func ].get (args [0 ])
316316                if  result  is  None :
317317                    result  =  func (* args )
318-                     cls . decorator_function_to_instance_map [func ].put (args [0 ], result )
318+                     decorator_function_to_instance_map [func ].put (args [0 ], result )
319319                return  result 
320320
321321            def  cache_info () ->  LRUCache [T , U ]:
322-                 return  cls . decorator_function_to_instance_map [func ]
322+                 return  decorator_function_to_instance_map [func ]
323323
324324            setattr (cache_decorator_wrapper , "cache_info" , cache_info )  # noqa: B010 
325325
0 commit comments