
    )i#                        S SK Jr  S SKrS SKJr  S SKJr  \" S/ SQ5      r\R                  " \R                  5      \R                  \R                  4S j5       r	 " S S	\5      r\" 5       4\\1\\\4S
 jrSS jrS rg)    )absolute_importN)
namedtuple)RLock
_CacheInfo)hitsmissesmaxsizecurrsizec                 p   ^ [        U4S jU 5       5      n[        R                  " U TX#5      n TU l        U $ )z-
Patch two bugs in functools.update_wrapper.
c              3   N   >#    U  H  n[        TU5      (       d  M  Uv   M     g 7fN)hasattr).0attrwrappeds     ]/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/backports/functools_lru_cache.py	<genexpr>!update_wrapper.<locals>.<genexpr>   s     Ihd''42HTThs   %	%)tuple	functoolsupdate_wrapper__wrapped__)wrapperr   assignedupdateds    `  r   r   r   
   s6     IhIIH&&wKG!GN    c                   .    \ rS rSrSrSr\4S jrS rSr	g)
_HashedSeq   zThis class guarantees that hash() will be called no more than once
per element.  This is important because the lru_cache() will hash
the key multiple times on a cache miss.

	hashvaluec                 &    XS S & U" U5      U l         g r   r    )selftuphashs      r   __init___HashedSeq.__init__%   s    Qcr   c                     U R                   $ r   r"   )r#   s    r   __hash___HashedSeq.__hash__)   s    ~~r   r"   N)
__name__
__module____qualname____firstlineno____doc__	__slots__r%   r&   r)   __static_attributes__ r   r   r   r      s     I!% #r   r   c                 4  ^ U nU(       a  X-  nUR                  5        H  n	X-  nM	     U(       a>  X" U4S jU  5       5      -  nU(       a"  X" U4S jUR                  5        5       5      -  nO U" U5      S:X  a  T" US   5      U;   a  US   $ [        U5      $ )ay  Make a cache key from optionally typed positional and keyword arguments

The key is constructed in a way that is flat as possible rather than
as a nested structure that would take more memory.

If there is only a single argument and its data type is known to cache
its hash value, then that argument is returned without a wrapper.  This
saves space and improves lookup speed.

c              3   4   >#    U  H  nT" U5      v   M     g 7fr   r2   r   vtypes     r   r   _make_key.<locals>.<genexpr>K   s     +dT!WWd   c              3   4   >#    U  H  nT" U5      v   M     g 7fr   r2   r5   s     r   r   r8   M   s     8-Qa-r9      r   )itemsvaluesr   )
argskwdstypedkwd_mark	fasttypesr   r7   lenkeyitems
         `   r   	_make_keyrF   -   s    0 CJJLDKC !u+d+++58$++-888C	SQ4A<941vc?r   c                   ^ ^ [        T [        5      (       a	  T S:  a  Sm Oa[        T 5      (       aC  [        T[        5      (       a.  T Ssnm [	        UT T[
        5      nU U4S jUl        [        X25      $ T b  [        S5      eU U4S jnU$ )a  Least-recently-used cache decorator.

If *maxsize* is set to None, the LRU features are disabled and the cache
can grow without bound.

If *typed* is True, arguments of different types will be cached separately.
For example, f(decimal.Decimal("3.0")) and f(3.0) will be treated as
distinct calls with distinct results. Some types such as str and int may
be cached separately even when typed is false.

Arguments to the cached function must be hashable.

View the cache statistics named tuple (hits, misses, maxsize, currsize)
with f.cache_info().  Clear the cache and statistics with f.cache_clear().
Access the underlying function with f.__wrapped__.

See:  https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)

r      c                     > T TS.$ Nr	   r@   r2   rK   s   r   <lambda>lru_cache.<locals>.<lambda>u   
    w+Or   z=Expected first argument to be an integer, a callable, or Nonec                 V   > [        U TT[        5      nUU4S jUl        [        X5      $ )Nc                     > T TS.$ rJ   r2   rK   s   r   rL   8lru_cache.<locals>.decorating_function.<locals>.<lambda>|   rN   r   )_lru_cache_wrapperr   cache_parametersr   )user_functionr   r	   r@   s     r   decorating_function&lru_cache.<locals>.decorating_functionz   s&    $]GUJO#O g55r   )	
isinstanceintcallableboolrR   r   rS   r   	TypeError)r	   r@   rT   r   rU   s   ``   r   	lru_cacher\   S   s    4 '3Q;G	'		z%66!(#w$]GUJO#O g55		WXX6
 r   c                 n  ^ ^^^^^^	^
^^^^^^^^^^ [        5       m[        mSu  m	mmm
0 mS=mmSmTR                  mTR                  m[	        5       m/ mTTS S /TS S & TS:X  a  UU 4S jnO&Tc  UUUUUUUU 4S jnOUUU	U
UUUUUUUUUUUU 4S jnUUUUUU4S jnUUUUUU4S jnXTl        Xdl        U$ )	N)r   r;         r   Fc                  "   > TS-  mT" U 0 UD6nU$ Nr;   r2   )r>   r?   resultr   rT   s      r   r   #_lru_cache_wrapper.<locals>.wrapper   s"     aKF"D1D1FMr   c                  h   > T" XT
5      nT" UT	5      nUT	La  TS-  mU$ TS-  mT" U 0 UD6nUTU'   U$ ra   r2   )r>   r?   rD   rb   cache	cache_getr   make_keyr   sentinelr@   rT   s       r   r   rc      sY     4u-CsH-FX%	aKF"D1D1FE#JMr   c                    > T" XT5      nT   T" U5      nUb5  Uu  pEpgXTT'   XET'   TT   nU=UT'   TT'   XT'   TUT'   TS-  mUsS S S 5        $ TS-  mS S S 5        T" U 0 UD6nT   UT;   a  OQT(       a'  Tn	X)T'   XyT'   U	T   mTT   n
S =TT'   TT'   TU
	 U	TU'   O#TT   nUTX'/nU=UT'   =TT'   TU'   T" 5       T:  mS S S 5        U$ ! , (       d  f       N{= f! , (       d  f       U$ = fra   r2   )r>   r?   rD   link	link_prev	link_next_keyrb   lastoldrootoldkeyKEYNEXTPREVRESULTre   rf   	cache_lenfullr   lockrg   r	   r   rootr@   rT   s              r   r   rc      s^    4u-C ~#9=6I$&/dO&/dO:D.22DJd!%J!%DJAID!  !  #D1D1F%<
 "G#&CL&,FO #4=D!#YF/33DIVf ")E#J  :D $4D;??DJ?deCj %;'1DE F Me  F Ms   7CC%AC
C
C(c                  ^   > T   T " TTTT" 5       5      sSSS5        $ ! , (       d  f       g= f)zReport cache statisticsNr2   )r   ru   r   rw   r	   r   s   r   
cache_info&_lru_cache_wrapper.<locals>.cache_info   s     dFGY[A TTs   
,c                  |   > T   T R                  5         TTSS/TSS& S=mmSmSSS5        g! , (       d  f       g= f)z$Clear the cache and cache statisticsNr   F)clear)re   rv   r   rw   r   rx   s   r   cache_clear'_lru_cache_wrapper.<locals>.cache_clear   s<     KKMT4.DGD6D	 TTs    -
;)objectrF   get__len__r   rz   r~   )rT   r	   r@   r   r   rz   r~   rq   rr   rs   rt   re   rf   ru   rv   r   rw   rg   r   rx   rh   s   ````   @@@@@@@@@@@@@@r   rR   rR      s    xHH(D$VED6D		II7DDT4&DG!|	 
	 	6	 6	 6	pB B
  $%Nr   )rH   F)
__future__r   r   collectionsr   	threadingr   r   wrapsr   WRAPPER_ASSIGNMENTSWRAPPER_UPDATESlistr   r   rX   strr   r7   rC   rF   r\   rR   r2   r   r   <module>r      s    &  " &OP
 ))* **%%	 +" * h[Cj
	#L,^qr   