
    h                       S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	J
r
JrJrJrJr  / SQr\" S\S9r\" S5      r " S	 S
\
\\4   5      r\" S\\S4   S9r\" S5      r " S S\	\\4   5      r\" S\S\4   S9rSSS jjrg)    )annotations)deque)wraps)AnyCallableDictGenericHashableTupleTypeVarcast)SimpleCacheFastDictCachememoized_T)bound_Uc                  :    \ rS rSrSrSS	S jjrS
S jrSS jrSrg)r      z
Very simple cache that discards the oldest item when the cache size is
exceeded.

:param maxsize: Maximum size of the cache. (Don't make it too big.)
c                L    US:  d   e0 U l         [        5       U l        Xl        g Nr   )_datar   _keysmaxsize)selfr   s     gC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\prompt_toolkit/cache.py__init__SimpleCache.__init__   s#    {{#%
 %
#    c                X    U R                   U   $ ! [         a    U" 5       nX0R                   U'   U R                  R                  U5        [	        U R                   5      U R
                  :  a6  U R                  R                  5       nX@R                   ;   a  U R                   U	 Us $ f = f)zz
Get object from the cache.
If not found, call `getter_func` to resolve it, and put that on the top
of the cache instead.
)r   KeyErrorr   appendlenr   popleft)r   keygetter_funcvaluekey_to_removes        r   getSimpleCache.get    s    	::c?" 	ME#JJsOJJc" 4::- $

 2 2 4 JJ.

=1L	s    BB)(B)c                0    0 U l         [        5       U l        g)zClear cache.N)r   r   r   )r   s    r   clearSimpleCache.clear7   s    
W
r   )r   r   r   N)   )r   intreturnNone)r%   r   r&   zCallable[[], _U]r0   r   )r0   r1   )	__name__
__module____qualname____firstlineno____doc__r   r)   r,   __static_attributes__ r   r   r   r      s    $.r   r   _K._Vc                  0    \ rS rSrSrSSS jjrS	S jrSrg)
r   A   a  
Fast, lightweight cache which keeps at most `size` items.
It will discard the oldest items in the cache first.

The cache is a dictionary, which doesn't keep track of access counts.
It is perfect to cache little immutable objects which are not expensive to
create, but where a dictionary lookup is still much faster than an object
instantiation.

:param get_value: Callable that's called in case of a missing key.
c                J    US:  d   e[        5       U l        Xl        X l        g r   )r   r   	get_valuesize)r   r>   r?   s      r   r   FastDictCache.__init__V   s     axx %
"	r   c                    [        U 5      U R                  :  a!  U R                  R                  5       nX ;   a  X	 U R                  " U6 nX0U'   U R                  R                  U5        U$ N)r#   r?   r   r$   r>   r"   )r   r%   r(   results       r   __missing__FastDictCache.__missing__]   s\    t9tyy  JJ..0M$'%S	

#r   )r   r>   r?   N)i@B )r>   zCallable[..., _V]r?   r/   r0   r1   )r%   r9   r0   r:   )r2   r3   r4   r5   r6   r   rD   r7   r8   r   r   r   r   A   s    
(
r   r   _Fc                   ^  SU 4S jjnU$ )zA
Memoization decorator for immutable classes and pure functions.
c                h   >^ ^ [        TS9m[        T 5      SUU 4S jj5       n[        [        U5      $ )N)r   c                    >^ ^ SU UU4S jjnT [        [        TR                  5       5      5      4nTR                  X25      $ )Nc                    > T" T 0 TD6$ rB   r8   )akwobjs   r   
create_newEmemoized.<locals>.decorator.<locals>.new_callable.<locals>.create_neww   s    A}}$r   )r0   r   )tuplesorteditemsr)   )rK   rL   rN   r%   cacherM   s   ``  r   new_callable1memoized.<locals>.decorator.<locals>.new_callableu   s8    % % eF288:./0C99S--r   )rK   r   rL   r   r0   r   )r   r   r   rF   )rM   rT   rS   r   s   ` @r   	decoratormemoized.<locals>.decoratorr   s2    ,7,H	s	. 
	. B%%r   )rM   rF   r0   rF   r8   )r   rV   s   ` r   r   r   m   s    
& r   N)i   )r   r/   r0   zCallable[[_F], _F])
__future__r   collectionsr   	functoolsr   typingr   r   r   r	   r
   r   r   r   __all__r   r   r   r9   r:   r   objectrF   r   r8   r   r   <module>r^      s    "   O O O T"T])'"b&/ )X Tx}-.T]&DRL &R T#v+./r   