
    MhZ                         U d Z ddlZddlmZ ddlmZmZmZ ddlm	Z	 ddl
mZ i aeeeeeeef         f         f         ed<   dd	ed
dfdZd Zd Zd ZdS )a7  
This caching is very important for speed and memory optimizations. There's
nothing really spectacular, just some decorators. The following cache types are
available:

- ``time_cache`` can be used to cache something for just a limited time span,
  which can be useful if there's user interaction and the user cannot react
  faster than a certain time.

This module is one of the reasons why |jedi| is not thread-safe. As you can see
there are global variables, which are holding the cache information. Some of
these variables are being cleaned after every API usage.
    Nwraps)AnyDictTuple)settings)parser_cache_time_cachesF
delete_allreturnc                 T   | rEt                                           D ]}|                                 t          j                     dS t                                           D ]F}t	          |                                          D ]"\  }\  }}|t          j                    k     r||= #GdS )z Jedi caches many things, that should be completed after each completion
    finishes.

    :param delete_all: Deletes also the cache that is normally not deleted,
        like parser cache, which is important for faster parsing.
    N)r
   valuesclearr	   listitemstime)r   cachetckeytvalues         J/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jedi/cache.pyclear_time_cachesr      s       !((** 	 	EKKMMMM %%'' 	  	 B#'

#3#3    Zaty{{??3 	  	     c                       fd}|S )a\  
    This decorator works as follows: Call it with a setting and after that
    use the function with a callable that returns the key.
    But: This function is only called if the key is not available. After a
    certain amount of time (`time_add_setting`) the cache is invalid.

    If the given key is None, the function will not be cached.
    c                 2     i t           <    fd}|S )Nc                  $    | i |}t          |          }	 |         \  }}|t          j                    k    r|S n# t          $ r Y nw xY wt          |          }t          t          	          }|t          j                    |z   |f|<   |S N)nextr   KeyErrorgetattrr   )
argskwargs	generatorr   expiryr   time_adddctkey_functime_add_settings
          r   wrapperz4signature_time_cache.<locals>._temp.<locals>.wrapper<   s     $1&11Iy//C #CDIKK'' L (    OOEx)9::H9;;158CLs   #? 
AA)r
   )r(   r*   r'   r)   s   ` @r   _tempz#signature_time_cache.<locals>._temp8   s?    ),%&	 	 	 	 	 	 	 r    )r)   r+   s   ` r   signature_time_cacher-   /   s#        ( Lr   c                       fd}|S )Nc                 \     i t                      fd            }fd|_        |S )Nc                      | t          |                                          f}	 |         \  }}t          j                    |z   k     r|S n# t          $ r Y nw xY w | i |}t          j                    |f|<   |S r   )	frozensetr   r   r    )r"   r#   r   createdresultr   funcsecondss        r   r*   z.time_cache.<locals>.decorator.<locals>.wrapperS   s    6<<>>223C"'*9;;7!222!M 3   T4*6**Ff,E#JMs   &A 
AAc                  ,                                      S r   )r   )r   s   r   <lambda>z/time_cache.<locals>.decorator.<locals>.<lambda>`   s    ekkmm r   )r   clear_cache)r4   r*   r   r5   s   ` @r   	decoratorztime_cache.<locals>.decoratorP   sU    	t
	 
	 
	 
	 
	 
	 

	 4333r   r,   )r5   r9   s   ` r   
time_cacher:   O   s$        & r   c                 <     t                      fd            }|S )zA normal memoize function.c                    | j                             di           }|                    i           }|t          |                                          f}	 ||         S # t          $ r  | g|R i |}|||<   |cY S w xY w)N_memoize_method_dct)__dict__
setdefaultr1   r   r    )selfr"   r#   
cache_dictr'   r   r3   methods          r   r*   zmemoize_method.<locals>.wrapperh   s    ]--.CRHH
##FB//Yv||~~../	s8O 	 	 	VD24222622FCHMMM	s   A A?>A?r   )rB   r*   s   ` r   memoize_methodrC   f   s3    
6]]	 	 	 	 ]	 Nr   )F)__doc__r   	functoolsr   typingr   r   r   jedir   parso.cacher	   r
   strfloat__annotations__boolr   r-   r:   rC   r,   r   r   <module>rM      s             # # # # # # # # # #       $ $ $ $ $ $8:d3S%s
"33445 : : :   $  4        .  @  .    r   