
    fZ                         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y)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_caches
delete_allreturnc                 4   | r>t         j                         D ]  }|j                           t        j                          yt         j                         D ]A  }t	        |j                               D ]#  \  }\  }}|t        j                         k  s!||= % C y)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         E/var/www/cvtools/html/venv/lib/python3.12/site-packages/jedi/cache.pyclear_time_cachesr      s     !((* 	EKKM	 %%' 	 B#'
#3  Zatyy{?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                 0     i t         <    fd}|S )Nc                      | i |}t        |      }	 |   \  }}|t        j                         kD  r|S 	 t        |      }t        t        	      }|t        j                         |z   |f|<   |S # t        $ r Y Fw xY w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&1Iy/C #CDIIK' L (
 OEx)9:H99;158CL  s    A3 3	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                 N     i t                fd       }fd|_        |S )Nc                      | t        |j                               f}	 |   \  }}t        j                         |z   k  r|S 	  | i |}t        j                         |f|<   |S # t        $ r Y .w xY wr   )	frozensetr   r   r    )r"   r#   r   createdresultr   funcsecondss        r   r*   z.time_cache.<locals>.decorator.<locals>.wrapperS   s    6<<>23C"'*99;7!22!M 3 4*6*Ff,E#JM	  s   #A& &	A21A2c                  $     j                         S r   )r   )r   s   r   <lambda>z/time_cache.<locals>.decorator.<locals>.<lambda>`   s    ekkm r   )r   clear_cache)r4   r*   r   r5   s   ` @r   	decoratorztime_cache.<locals>.decoratorP   s-    	t
	 

	 4r   r,   )r5   r9   s   ` r   
time_cacher:   O   s    & r   c                 .     t                fd       }|S )zA normal memoize function.c                     | j                   j                  di       }|j                  i       }|t        |j                               f}	 ||   S # t        $ r  | g|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
##FB/Yv||~./	s8O 	D24262FCHM	s   A A0/A0r   )rB   r*   s   ` r   memoize_methodrC   f   s     
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      sh      # #  $8:d3S%s
"33445 : $  4  .@.r   