
    4j#                     ~    S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	  SSK
Jr   " S S	\5      r " S
 S\5      rSS jrg)a  Caching decorators. Currently provides ``lru_cache``, a drop-in
replacement for ``functools.lru_cache`` with correct handling of instance
methods: a separate cache is maintained per instance, stored as an
attribute on the instance itself so it is cleaned up with the instance
by the garbage collector. For plain functions, class methods, and static
methods a single shared cache is used, matching ``functools.lru_cache``.
    )	lru_cache)partial   )BoundFunctionWrapperFunctionWrapper)	decorator)synchronizedc                   2    \ rS rSrS rS rS rS rS rSr	g)	_BoundLRUCacheFunctionWrapper!   c                      U R                   S:H  $ )Nfunction)_self_bindingselfs    L/root/lseg-credit/backend/venv/lib/python3.13/site-packages/wrapt/caching.py_is_instance_method1_BoundLRUCacheFunctionWrapper._is_instance_method#   s    !!Z//    c                 b   U R                   nU R                  5       (       dj  UR                  cK  [        U5         UR                  c*  [	        S0 UR
                  D6" U R                  5      Ul        S S S 5        UR                  " U0 UD6$ U R                  nUR                  n[        XES 5      nUcT  [        U5         [        XES 5      nUc1  [	        S0 UR
                  D6" U R                  5      n[        XEU5        S S S 5        U" U0 UD6$ ! , (       d  f       N= f! , (       d  f       N'= fN )_self_parentr   _self_cacher	   _functools_lru_cache_self_lru_kwargs__wrapped___self_instance_self_cache_attrgetattrsetattr)r   argskwargsparentinstance
cache_attrcaches          r   __call__&_BoundLRUCacheFunctionWrapper.__call__&   s   "" ''))!!)!&)))1-A .$55.**.,* * %%t6v66 &&,,
d3=f%d;=0K63J3JK((E H%8 & d%f%%9 *)$ &%s   8D>AD 
D 
D.c                     U R                  5       (       d  U R                  R                  5       $ [        U R                  U R                  R
                  S5      nUb  UR                  5       $ g)ziReturn the cache statistics for this binding's cache, or
``None`` if the cache has not yet been created.
N)r   r   
cache_infor    r   r   r   r'   s     r   r+   (_BoundLRUCacheFunctionWrapper.cache_infoN   sa    
 ''))$$//11++T->->-O-OQUV##%%r   c                     U R                  5       (       d  U R                  R                  5         g[        U R                  U R                  R
                  S5      nUb  UR                  5         gg)zClear this binding's cache.N)r   r   cache_clearr    r   r   r,   s     r   r/   )_BoundLRUCacheFunctionWrapper.cache_clear]   s`     ''))))+++T->->-O-OQUV r   c                     U R                  5       (       d  U R                  R                  5       $ [        U R                  U R                  R
                  S5      nUb  UR                  5       $ g)z/Return the parameters used to create the cache.N)r   r   cache_parametersr    r   r   r,   s     r   r2   ._BoundLRUCacheFunctionWrapper.cache_parametersi   sa     ''))$$5577++T->->-O-OQUV))++r   r   N)
__name__
__module____qualname____firstlineno__r   r(   r+   r/   r2   __static_attributes__r   r   r   r   r   !   s    0&&P
 r   r   c                   D   ^  \ rS rSr\rU 4S jrS rS rS r	S r
SrU =r$ )_LRUCacheFunctionWrapperw   c                    > [         TU ]  " X40 UD6  UR                  U l        S U l        [	        USS 5      nUc  UR
                  R                  nSU-   U l        g )Nr4   _lru_cache_)super__init__r   r   r    __func__r4   r   )r   wrappedwrapperr#   name	__class__s        r   r?   !_LRUCacheFunctionWrapper.__init__{   s`    4V4
 !( 8 8
 w
D1<##,,D - 4r   c                     U R                   cK  [        U 5         U R                   c*  [        S0 U R                  D6" U R                  5      U l         S S S 5        U R                   " U0 UD6$ ! , (       d  f       N = fr   )r   r	   r   r   r   )r   r"   r#   s      r   r(   !_LRUCacheFunctionWrapper.__call__   sn     #d###+';'Td>S>S'T(((D$ $ 000 $#s   8A++
A9c                 R    U R                   b  U R                   R                  5       $ g)zPReturn the cache statistics, or ``None`` if the cache has
not yet been created.
N)r   r+   r   s    r   r+   #_LRUCacheFunctionWrapper.cache_info   s(    
 '##..00r   c                 T    U R                   b  U R                   R                  5         gg)z)Clear the cache and reset the statistics.N)r   r/   r   s    r   r/   $_LRUCacheFunctionWrapper.cache_clear   s'     '((* (r   c                 R    U R                   b  U R                   R                  5       $ g)zcReturn the parameters used to create the cache, or ``None``
if the cache has not yet been created.
N)r   r2   r   s    r   r2   )_LRUCacheFunctionWrapper.cache_parameters   s(    
 '##4466r   )r   r   r   )r4   r5   r6   r7   r   __bound_function_wrapper__r?   r(   r+   r/   r2   r8   __classcell__)rD   s   @r   r:   r:   w   s'    !>5&1+ r   r:   Nc                b    U c  [        [        40 UD6$ S nXl        [        U[        S9" U 5      $ )as  A decorator that applies ``functools.lru_cache`` to the wrapped
function, with correct handling for instance methods, class methods,
and static methods.

For instance methods, a separate ``functools.lru_cache`` is
maintained per instance. The cache is stored as an attribute on the
instance itself, so it is automatically cleaned up when the instance
is garbage collected. This means instances do not need to be
hashable, each instance gets its own full ``maxsize`` budget, and
no external mapping prevents garbage collection.

For plain functions, class methods, and static methods, a single
shared cache is used.

All keyword arguments are passed through to ``functools.lru_cache``.

Cache management methods ``cache_info()`` and ``cache_clear()`` are
available directly on the decorated function. For bound methods,
these operate on the per-instance cache for the bound instance.
c                     U " U0 UD6$ Nr   )rA   r%   r"   _kwargss       r   _wrapperlru_cache.<locals>._wrapper   s    (((r   )proxy)r   r   r   r   r:   )funcr#   rT   s      r   r   r      s9    , |y+F++) !'X%=>tDDr   rR   )__doc__	functoolsr   r   r   	__wrapt__r   r   
decoratorsr   synchronizationr	   r   r:   r   r   r   <module>r]      s>    8  < ! )&S$8 Sl< <~Er   